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

SiteMap.CurrentNode Property

Note: This property is new in the .NET Framework version 2.0.

Gets a SiteMapNode control that represents the currently requested page.

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

public static SiteMapNode CurrentNode { get; }
/** @property */
public static SiteMapNode get_CurrentNode ()

public static function get CurrentNode () : SiteMapNode

Property Value

A SiteMapNode instance that represents the currently requested page; otherwise, a null reference (Nothing in Visual Basic), if no representative node exists in the site map information.

Exception typeCondition


The site map feature is not enabled.


The default provider specified in the configuration does not exist.


The feature is supported only when running in Low trust or higher.

The SiteMap class retrieves the CurrentNode property by requesting it from the provider.

If no representative node exists for the page in the site map information, or if security trimming is enabled and the node cannot be returned for the current user, a null reference (Nothing in Visual Basic) is returned.

The SiteMapResolve event is raised by the default site map provider if one or more subscriptions exist.

If you implement your own SiteMapProvider object, you might create your own mechanism to find and retrieve the CurrentNode. However, if you extend the StaticSiteMapProvider class and use a URL-based scheme to identify pages, you can override the FindSiteMapNode method.

The following code example demonstrates how to use the CurrentNode property to retrieve the SiteMapNode object that represents the current page.

<Script runat="server">
private void Page_Load(object sender, System.EventArgs e)
    // Examine the CurrentNode, and navigate the SiteMap relative to it.
    Response.Write(SiteMap.CurrentNode.Title + "<BR>");
    Response.Write("<FONT COLOR='red'>" + SiteMap.CurrentNode.Url + "</FONT><BR>");

    // What nodes are children of the CurrentNode?
    if (SiteMap.CurrentNode.HasChildNodes) {
        IEnumerator childNodesEnumerator = SiteMap.CurrentNode.ChildNodes.GetEnumerator();
        while (childNodesEnumerator.MoveNext()) {
            // Prints the Title of each node.
            Response.Write(childNodesEnumerator.Current.ToString() + "<BR>");

    // Examine the RootNode, and navigate the SiteMap relative to it.
    Response.Write(SiteMap.RootNode.Title + "<BR>");
    Response.Write(SiteMap.RootNode.Url + "<BR>");

    // What nodes are children of the RootNode?
    if (SiteMap.RootNode.HasChildNodes) {
        IEnumerator rootNodesChildrenEnumerator = SiteMap.RootNode.ChildNodes.GetEnumerator();
        while (rootNodesChildrenEnumerator.MoveNext()) {
            // Prints the Title of each node.
            Response.Write(rootNodesChildrenEnumerator.Current.ToString() + "<BR>");

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions

© 2015 Microsoft