Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

SiteMapProvider.CurrentNode Property

Gets the SiteMapNode object that represents the currently requested page.

Namespace:  System.Web
Assembly:  System.Web (in System.Web.dll)

public virtual SiteMapNode CurrentNode { get; }

Property Value

Type: System.Web.SiteMapNode
A SiteMapNode that represents the currently requested page; otherwise, null, if the SiteMapNode is not found or cannot be returned for the current user.

The SiteMapResolve event is raised before attempting to retrieve a SiteMapNode object, to enable event subscribers to return an instance of the SiteMapNode class. If there are no event subscribers, the SiteMapProvider class calls the FindSiteMapNode method using the current HTTP context to retrieve a SiteMapNode that represents the currently requested page.

If the currently requested page does not correspond with a SiteMapNode, null is returned. If security trimming is enabled and the user is not permitted to access the SiteMapNode, null is returned.

TopicLocation
How to: Programmatically Modify Site-Map Nodes in MemoryBuilding ASP .NET Web Applications
How to: Programmatically Modify Site-Map Nodes in MemoryBuilding ASP .NET Web Applications

The following code example demonstrates how to implement the CurrentNode property in a class that implements the abstract SiteMapProvider class.

This code example is part of a larger example provided for the SiteMapProvider class.

// Implement the CurrentNode property. 
public override SiteMapNode CurrentNode
{
  get
  {
    string currentUrl = FindCurrentUrl();
    // Find the SiteMapNode that represents the current page.
    SiteMapNode currentNode = FindSiteMapNode(currentUrl);
    return currentNode;
  }
}

// Implement the RootNode property. 
public override SiteMapNode RootNode
{
  get
  {
    return rootNode;
  }
}

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0
Show:
© 2015 Microsoft