You could try getting the full path of page being requested from server object then try umbraco.library.GetXmlNodeByXPath from there get the doc id then do as per slace's suggestion? Not very clean but I do recall doing something similar a while back.
I have not been able to get the Current node (at least not in any sort of convenient manner) in a HTTP Module (or generic handler) so far...always fallen back on a less-than-elegant hack. Which brings up an intersting question we've debated a bit:
If you are executing in a Module (or handler) *IS* there a Current Node?
Not adding lots to this thread but perhaps the solution will help answer the question.
Oh good point Paul, since a Module is executed within the request pipeline of IIS regardless of the request type ;)
If you're after a less-than-elegant hack you could always access HttpContext.Items["pageID"], that *may* be set (it's actually what is used internally by the UmbracContext)
Accessing current node in a HTTPModule
Hi,
I try to retrieve the current node in a HTTPmodule but "umbraco.presentation.nodeFactory.Node.GetCurrent()" always return null.
How can I access the current node in a HTTPModule?
Thanks,
L.
you can try Document current = new Document(Node.GetCurrent().Id);
Like I said, Node.GetCurrent() always return NULL in my HTTPModule. Maybe it's too early in the umbraco process and the "context" is not already set.
Try constructing a new instance of a Node using the UmbracoContext as the ID source:
PageId is a nullable int (int?) so make sure you null check it first
The PageID is always Null at this time.
Luc,
You could try getting the full path of page being requested from server object then try umbraco.library.GetXmlNodeByXPath from there get the doc id then do as per slace's suggestion? Not very clean but I do recall doing something similar a while back.
Regards
Ismail
Hmm... I'll have a look at when the context is created vs when you're executing your request
I have not been able to get the Current node (at least not in any sort of convenient manner) in a HTTP Module (or generic handler) so far...always fallen back on a less-than-elegant hack. Which brings up an intersting question we've debated a bit:
If you are executing in a Module (or handler) *IS* there a Current Node?
Not adding lots to this thread but perhaps the solution will help answer the question.
-Paul
Oh good point Paul, since a Module is executed within the request pipeline of IIS regardless of the request type ;)
If you're after a less-than-elegant hack you could always access HttpContext.Items["pageID"], that *may* be set (it's actually what is used internally by the UmbracContext)
is working on a reply...