System.Web.StaticSiteMapProvider Class

Serves as a partial implementation of the abstract System.Web.SiteMapProvider class and serves as a base class for the System.Web.XmlSiteMapProvider class, which is the default site map provider in ASP.NET.

See Also: StaticSiteMapProvider Members


public abstract class StaticSiteMapProvider : SiteMapProvider


The System.Web.StaticSiteMapProvider class is a partial implementation of the abstract System.Web.SiteMapProvider class and supplies two additional methods: erload:System.Web.StaticSiteMapProvider.AddNode and StaticSiteMapProvider.RemoveNode(SiteMapNode), as well as the abstract StaticSiteMapProvider.BuildSiteMap and protected StaticSiteMapProvider.Clear methods.

The System.Web.StaticSiteMapProvider class supports writing a site map provider (for example, an System.Web.XmlSiteMapProvider) that translates a site map that is stored in persistent storage to one that is stored in memory. The System.Web.StaticSiteMapProvider class provides basic implementations for storing and retrieving System.Web.SiteMapNode objects.

The System.Web.SiteMapProvider and System.Web.StaticSiteMapProvider classes support the concept of a site map provider hierarchy, where a site map provider can have a hierarchical relationship with other site map providers. This pattern is implemented with the SiteMapProvider.RootProvider and SiteMapProvider.ParentProvider properties.

The System.Web.StaticSiteMapProvider class stores its System.Web.SiteMapNode objects in hash tables and internally uses the SiteMapNode.Url property of the pages, represented by site map nodes, as keys. (If a site map node does not specify a URL, it is tracked using an automatically generated unique key.) As a result, you cannot have site map nodes wherein a site map node with the same URL is used more than once. For example, attempting to load the site map node illustrated in the following code example with the System.Web.XmlSiteMapProvider class, which is the default ASP.NET site map provider, or any site map provider that is derived from the System.Web.StaticSiteMapProvider class will not work because the AboutUs.aspx page is used more than once.


  <sitemapnode title="Home" description="Home" url="default.aspx" >
    <sitemapnode title="Catalog" description="Our catalog" url="catalog.aspx"/>
    <sitemapnode title="About Us" description="All about our company" url="aboutus.aspx"/>
    <sitemapnode title="Driving Directions" description="Directions to our store" url="aboutus.aspx"/>

If you are extending the System.Web.StaticSiteMapProvider class, the three most important methods are the SiteMapProvider.GetRootNodeCore, System.Configuration.Provider.ProviderBase.Initialize(string, System.Collections.Specialized.NameValueCollection), and StaticSiteMapProvider.BuildSiteMap methods. The StaticSiteMapProvider.Clear and StaticSiteMapProvider.FindSiteMapNode(string) methods have default implementations that are sufficient for most custom site map provider implementations.

The System.Configuration.Provider.ProviderBase.Initialize(string, System.Collections.Specialized.NameValueCollection) method is called to initialize derived site map providers, including any resources that are required to load site map data, but it does attempt to build the site map node in memory. If your derived class is using files to store site map data, any file initialization can be performed here. If the site map node uses some other type of data store, such as a relational database, initializing a connection might be performed here. Additional attributes, such as file names or connection strings that are placed on the site map provider element in the configuration are processed by the ASP.NET configuration system and passed to the System.Configuration.Provider.ProviderBase.Initialize(string, System.Collections.Specialized.NameValueCollection) method with the attributes parameter.

The StaticSiteMapProvider.BuildSiteMap method must be overridden by all classes that are derived from the System.Web.StaticSiteMapProvider class and is called to load the site map node from persistent storage and convert it to an internal representation. The StaticSiteMapProvider.BuildSiteMap method is called internally in many of the default member implementations of the System.Web.StaticSiteMapProvider and System.Web.XmlSiteMapProvider classes. If you implement your own site map provider, ensure that site map data processing occurs once and subsequent calls to the StaticSiteMapProvider.BuildSiteMap method return immediately, if site map information has already been loaded. When you implement the StaticSiteMapProvider.BuildSiteMap method, ensure it is thread safe, as multiple concurrent page requests can result indirectly in multiple calls to load site map information. The site map infrastructure supports displaying site map information based on the user's role. Depending on the SiteMapNode.Roles property that are supported by the individual System.Web.SiteMapNode objects, a different navigation structure can exist for different users. The default implementations of the site map node retrieval members of the System.Web.StaticSiteMapProvider class perform security trimming automatically by calling the SiteMapProvider.IsAccessibleToUser(HttpContext, SiteMapNode) method.

The erload:System.Web.StaticSiteMapProvider.AddNode, StaticSiteMapProvider.Clear and StaticSiteMapProvider.RemoveNode(SiteMapNode) methods manipulate the internal collections that are used to track site map nodes in a thread-safe manner.


Namespace: System.Web
Assembly: System.Web (in System.Web.dll)
Assembly Versions:
Since: .NET 2.0