This documentation is archived and is not being maintained.

SiteMapNode.Url Property

Gets or sets the URL of the page that the SiteMapNode object represents.

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

public virtual string Url { get; set; }

Property Value

Type: System.String
The URL of the page that the node represents. The default is String.Empty.


The node is read-only.

The XmlSiteMapProvider class, which is the default site map provider implementation for ASP.NET, uses the SiteMapNode.Url property as a lookup key. Therefore, any SiteMapNode object that is used by the XmlSiteMapProvider class must have a unique URL within the scope of the provider.

Leading and trailing white-space characters are ignored.

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 set the Url property of a SiteMapNode object. The AccessSiteMapProvider stores its root node as a row that has no parentnodeid defined. The row is returned using an OleDbDataReader object, and SiteMapNode properties are set from the values in the data reader.

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

// Build an in-memory representation from persistent 
// storage, and return the root node of the site map. 
public override SiteMapNode BuildSiteMap() {

    // Since the SiteMap class is static, make sure that it is 
    // not modified while the site map is built.
    lock(this) {

        // If there is no initialization, this method is being 
        // called out of order. 
        if (! IsInitialized) {
            throw new Exception("BuildSiteMap called incorrectly.");

        // If there is no root node, then there is no site map. 
        if (null == rootNode) {
            // Start with a clean slate

            // Select the root node of the site map from Microsoft Access. 
            int rootNodeId = -1;

            if (accessConnection.State == ConnectionState.Closed)
            OleDbCommand rootNodeCommand =
                new OleDbCommand("SELECT nodeid, url, name FROM SiteMap WHERE parentnodeid IS NULL",
            OleDbDataReader rootNodeReader = rootNodeCommand.ExecuteReader();

            if(rootNodeReader.HasRows) {
                rootNodeId = rootNodeReader.GetInt32(0);
                // Create a SiteMapNode that references the current StaticSiteMapProvider.
                rootNode   = new SiteMapNode(this,

            else return null;

            // Select the child nodes of the root node.
            OleDbCommand childNodesCommand =
                new OleDbCommand("SELECT nodeid, url, name FROM SiteMap WHERE parentnodeid = ?",
            OleDbParameter rootParam = new OleDbParameter("parentid", OleDbType.Integer);
            rootParam.Value = rootNodeId;

            OleDbDataReader childNodesReader = childNodesCommand.ExecuteReader();

            if (childNodesReader.HasRows) {

                SiteMapNode childNode = null;
                while(childNodesReader.Read()) {
                    childNode =  new SiteMapNode(this,

                    // Use the SiteMapNode AddNode method to add 
                    // the SiteMapNode to the ChildNodes collection.
                    AddNode(childNode, rootNode);

        return rootNode;

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

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

.NET Framework

Supported in: 3.5, 3.0, 2.0