Get the current node at the begin of the request
Hello,
Is there any way to get the current page node for each request? I tried to use "Telerik.Sitefinity.Web.SiteMapBase.GetActualCurrentNode()" and it is crashing in the "Application_BeginRequest" event expecting a value in the context user, for the "Application_AuthenticateRequest" and "Application_EndRequest" events the returned value is null.
Is there any other method to get the current node/page associated with the current request in the Global.asax file in one of these events?
Thanks.
Try this:
var currentProvider = SitefinitySiteMap.GetCurrentProvider()
as
SiteMapBase;
var currentNode = currentProvider.FindSiteMapNode(httpContext.Request.RawUrl,
false
);
/* don't forget that requests for images, stylesheets, etc will go through here. 'currentNode' for those resources will be null. */
Hello,
You can also use SiteMapBase.GetCurrentNode() and SiteMapBase.GetActualCurrentNode(). The second method can be used when you are on the first child page of a group page. It will return the child page instead of the group page.
Best wishes,
Radoslav Georgiev
the Telerik team