SiteMap.Provider Property

Gets the default SiteMapProvider object for the current site map.

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

public static SiteMapProvider Provider { get; }

Property Value

Type: System.Web.SiteMapProvider
The default site map provider for the SiteMap.

ExceptionCondition
InvalidOperationException

The site map feature is not enabled.

ConfigurationErrorsException

The default provider specified in the configuration does not exist.

HttpException

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

By default, the XmlSiteMapProvider object is used and site navigation data is loaded from the Web.sitemap file that is located in the root directory of the site. This is identified in the management classes that manage the site navigation configuration and the site map configuration section of the Web.config files. By default, it is an instance of the XmlSiteMapProvider class, which uses the Web.sitemap file as its persistent store. However, you can implement your own site map storage and configuration scheme by writing a class that implements the abstract SiteMapProvider class. For more information on writing your own provider, see SiteMapProvider.

The following code example demonstrates how to access the default SiteMapProvider object for the site by using the static Provider property.

<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<SCRIPT runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
    // Navigate the SiteMap built by the default SiteMapProvider.
    Response.Write(SiteMap.RootNode.ToString() + "<BR>");

    Response.Write(SiteMap.RootNode.Url + "<BR>");
    Response.Write(SiteMap.RootNode.Title + "<BR>");

    foreach (SiteMapNode sitemapnode in SiteMap.RootNode.ChildNodes)
    {
        // Iterate through the ChildNodes SiteMapNodesCollection 
        // maintained by the RootNode.
        Response.Write(sitemapnode.Url + "<BR>" );
    }

    IEnumerator providers = SiteMap.Providers.GetEnumerator();
    while (providers.MoveNext())
    {
        Response.Write(providers.Current);
        Response.Write("&nbsp;&nbsp;&nbsp;");
        Response.Write("<BR>");
    }
}
</SCRIPT>

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
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft