SiteMapProvider Class
Assembly: System.Web (in system.web.dll)
The StaticSiteMapProvider and XmlSiteMapProvider classes represent the default implementations of the abstract SiteMapProvider class. The XmlSiteMapProvider uses an XML file named Web.sitemap to store site map data. For more information on about the Web.sitemap file, see ASP.NET Site Maps.
The SiteMapProvider class supports the concept of a site map provider hierarchy, by declaring the RootProvider and ParentProvider properties. A SiteMapProvider can be a child or parent of another provider. This enables scenarios where different content areas of a site are owned or implemented by different development groups that maintain their own site maps and site map providers.
All SiteMapProvider objects are configured in the Web.config files. Any site map providers that are declared in these configuration files are loaded at run time and are used to load and process site navigation data. The SiteMap object, which keeps track of all the providers that are available to it through its Providers property collection, provides programmatic access to the navigation data that is managed by the providers. The following code example demonstrates the format that is used to declare a site map provider in a Web.config file.
<siteMap defaultProvider="<name>">
<providers>
<add
name="<friendly name>"
type="<class name>, <fully-qualified type name>"
siteMapFile = "<file name>" />
</providers>
</siteMap>
The site navigation data that is loaded by these providers is used by other components of the site map infrastructure, such as the SiteMapPath and TreeView controls, to display site map information for users.
If you implement your own site map provider, you can place the source file in the App_Code directory of your ASP.NET application, and then the assembly will be compiled automatically. You can also place your own site map provider in the Global Assembly Cache (GAC), and provide a fully-qualified reference to it in the Web.config file. For more information on compiler services, see Working with Assemblies and the Global Assembly Cache.
Notes to Inheritors: When you inherit from the SiteMapProvider class, you must override the following members: GetRootNodeCore, FindSiteMapNode, GetChildNodes, and GetParentNode.The following code example demonstrates how to write a class that implements the abstract SiteMapProvider class. The example uses a comma-delimited file that follows an expected structure to load site map information. The first line of the file represents the root node of the site map, and subsequent lines are subnodes. Each subnode identifies its parent node by URL. An example of a file that meets these criteria is shown below.
default.aspx,Home,MyCompany Home Page, sale.aspx,Now On Sale,Check Out These Great Deals!,default.aspx catalog.aspx,Online Catalog,Browse Our Many Great Items!,default.aspx
The SimpleTextSiteMapProvider provides example implementations of all the SiteMapProvider properties and methods.
- AspNetHostingPermission for operating in a hosted environment. Demand value: LinkDemand; Permission value: Minimal.
- AspNetHostingPermission for operating in a hosted environment. Demand value: InheritanceDemand; Permission value: Minimal.
System.Configuration.Provider.ProviderBase
System.Web.SiteMapProvider
System.Web.StaticSiteMapProvider