More in this section

Forums / General Discussions / Get the current node at the begin of the request

Get the current node at the begin of the request

3 posts, 0 answered
  1. AmrElsayed
    AmrElsayed avatar
    87 posts
    Registered:
    18 Jul 2012
    19 Oct 2011
    Link to this post
    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.
  2. Craig
    Craig avatar
    9 posts
    Registered:
    22 Feb 2011
    19 Oct 2011
    Link to this post
    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. */
  3. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    24 Oct 2011
    Link to this post
    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
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
3 posts, 0 answered