Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
371 lines (301 sloc) 27.1 KB
<Type Name="SiteMap" FullName="System.Web.SiteMap">
<TypeSignature Language="C#" Value="public static class SiteMap" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi abstract sealed beforefieldinit SiteMap extends System.Object" />
<TypeSignature Language="DocId" Value="T:System.Web.SiteMap" />
<TypeSignature Language="VB.NET" Value="Public Class SiteMap" />
<TypeSignature Language="C++ CLI" Value="public ref class SiteMap abstract sealed" />
<TypeSignature Language="F#" Value="type SiteMap = class" />
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Object</BaseTypeName>
</Base>
<Interfaces />
<Docs>
<summary>The <see cref="T:System.Web.SiteMap" /> class is an in-memory representation of the navigation structure for a site, which is provided by one or more site map providers. This class cannot be inherited.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Site maps are used in conjunction with the <xref:System.Web.UI.WebControls.SiteMapDataSource>, <xref:System.Web.UI.WebControls.SiteMapPath>, and other controls to render an effective navigation interface for users to navigate a Web site. A <xref:System.Web.SiteMap> object is a component of the ASP.NET site navigation infrastructure that provides access to read-only site map information for page and control developers using navigation and <xref:System.Web.UI.WebControls.SiteMapDataSource> controls. Other components of the ASP.NET site navigation infrastructure include the <xref:System.Web.SiteMapProvider> and <xref:System.Web.XmlSiteMapProvider> classes, the Web.sitemap file, and the various controls that work with the <xref:System.Web.SiteMap> class, such as the <xref:System.Web.UI.WebControls.SiteMapPath> control, to render content and menus.
The <xref:System.Web.SiteMap> has several functions:
- It provides the root node of the site navigation hierarchy (there can be only one root node).
- It identifies which site map provider is the principal, or default, provider.
- It keeps track of all the provider objects that are used to create the <xref:System.Web.SiteMap>.
Fundamentally, the <xref:System.Web.SiteMap> is a container for a hierarchical collection of <xref:System.Web.SiteMapNode> objects. However, the <xref:System.Web.SiteMap> does not maintain the relationships between the nodes; rather, it delegates this to the site map providers. The <xref:System.Web.SiteMap> acts as an interface to the site navigation information (in the form of <xref:System.Web.SiteMapNode> objects) that is held by these site map providers. It keeps track of the providers from which it can access site navigation data and exposes its <xref:System.Web.SiteMap.Providers%2A> collection. A provider can store its site map information in any way - as long as it extends the <xref:System.Web.SiteMapProvider> abstract class, the <xref:System.Web.SiteMap> class can be initialized successfully from it.
The default provider for the <xref:System.Web.SiteMap> class is the <xref:System.Web.XmlSiteMapProvider> class, which works with an XML configuration file, Web.sitemap. However, you can write your own <xref:System.Web.SiteMapProvider> object, and use it to initialize the site map for your site. For an example of a custom site map provider, see <xref:System.Web.SiteMapProvider>.
A default site map configuration is specified that manages the site navigation configuration. You can override this configuration in the Web.config file, should you choose to write your own site map provider.
The <xref:System.Web.SiteMap> class offers only static members for performance and it can be accessed at any time in a given site from a Web Form or Web server control.
## Examples
This section contains two code examples. The first code example demonstrates how to declare a site map provider in a Web.config file. The second code example demonstrates how to use a <xref:System.Web.SiteMap> object.
The following code example is a Web.config configuration section that demonstrates how an <xref:System.Web.XmlSiteMapProvider> object is declared as the default <xref:System.Web.SiteMapProvider> object.
```
<siteMap defaultProvider="MyXmlSiteMapProvider" enabled="true">
<providers>
<add name="MyXmlSiteMapProvider"
description="The site map provider that reads in the .sitemap XML files."
type="System.Web.XmlSiteMapProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
siteMapFile="my.sitemap" />
</providers>
</siteMap>
```
The following code example demonstrates how to use the <xref:System.Web.SiteMap> object by accessing its static members to display information about the <xref:System.Web.SiteMap.RootNode%2A> and <xref:System.Web.SiteMap.CurrentNode%2A> properties. Compare it to the output that is rendered by the <xref:System.Web.UI.WebControls.SiteMapPath> control.
[!code-aspx-csharp[System.Web.SiteMap_3#1](~/samples/snippets/csharp/VS_Snippets_WebNet/System.Web.SiteMap_3/CS/sitemapcs.aspx#1)]
[!code-aspx-vb[System.Web.SiteMap_3#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/System.Web.SiteMap_3/VB/sitemapvb.aspx#1)]
]]></format>
</remarks>
<altmember cref="T:System.Web.SiteMapNode" />
<altmember cref="T:System.Web.SiteMapProvider" />
<altmember cref="T:System.Web.SiteMapNodeCollection" />
<altmember cref="T:System.Web.SiteMapProviderCollection" />
<altmember cref="T:System.Web.UI.WebControls.SiteMapPath" />
<altmember cref="T:System.Web.UI.WebControls.TreeView" />
<related type="Article" href="https://msdn.microsoft.com/library/23de8a05-cac3-4693-b508-39f1d4b7053d">ASP.NET Site Navigation Overview</related>
<related type="Article" href="https://msdn.microsoft.com/library/6b85a558-1df8-44cf-bea6-62e61bcc8d20">ASP.NET Site Maps</related>
<related type="Article" href="https://msdn.microsoft.com/library/4f3ce72a-4fa3-4c3a-94c8-3e2bc4a92d85">ASP.NET Site Navigation Providers</related>
</Docs>
<Members>
<Member MemberName="CurrentNode">
<MemberSignature Language="C#" Value="public static System.Web.SiteMapNode CurrentNode { get; }" />
<MemberSignature Language="ILAsm" Value=".property class System.Web.SiteMapNode CurrentNode" />
<MemberSignature Language="DocId" Value="P:System.Web.SiteMap.CurrentNode" />
<MemberSignature Language="VB.NET" Value="Public Shared ReadOnly Property CurrentNode As SiteMapNode" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; static property System::Web::SiteMapNode ^ CurrentNode { System::Web::SiteMapNode ^ get(); };" />
<MemberSignature Language="F#" Value="member this.CurrentNode : System.Web.SiteMapNode" Usage="System.Web.SiteMap.CurrentNode" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Web.SiteMapNode</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets a <see cref="T:System.Web.SiteMapNode" /> control that represents the currently requested page.</summary>
<value>A <see cref="T:System.Web.SiteMapNode" /> instance that represents the currently requested page; otherwise, <see langword="null" />, if no representative node exists in the site map information.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.SiteMap> class retrieves the <xref:System.Web.SiteMap.CurrentNode%2A> 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, `null` is returned.
The <xref:System.Web.SiteMap.SiteMapResolve> event is raised by the default site map provider if one or more subscriptions exist.
If you implement your own <xref:System.Web.SiteMapProvider> object, you might create your own mechanism to find and retrieve the <xref:System.Web.SiteMapProvider.CurrentNode%2A>. However, if you extend the <xref:System.Web.StaticSiteMapProvider> class and use a URL-based scheme to identify pages, you can override the <xref:System.Web.StaticSiteMapProvider.FindSiteMapNode%2A> method.
## Examples
The following code example demonstrates how to use the <xref:System.Web.SiteMap.CurrentNode%2A> property to retrieve the <xref:System.Web.SiteMapNode> object that represents the current page.
[!code-aspx-csharp[System.Web.SiteMap_1#1](~/samples/snippets/csharp/VS_Snippets_WebNet/System.Web.SiteMap_1/CS/catalogcs.aspx#1)]
[!code-aspx-vb[System.Web.SiteMap_1#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/System.Web.SiteMap_1/VB/catalogvb.aspx#1)]
]]></format>
</remarks>
<exception cref="T:System.InvalidOperationException">The site map feature is not enabled.</exception>
<exception cref="T:System.Configuration.ConfigurationErrorsException">The default provider specified in the configuration does not exist.</exception>
<exception cref="T:System.Web.HttpException">The feature is supported only when running in Low trust or higher.</exception>
<altmember cref="P:System.Web.SiteMapProvider.CurrentNode" />
<altmember cref="E:System.Web.SiteMap.SiteMapResolve" />
</Docs>
</Member>
<Member MemberName="Enabled">
<MemberSignature Language="C#" Value="public static bool Enabled { get; }" />
<MemberSignature Language="ILAsm" Value=".property bool Enabled" />
<MemberSignature Language="DocId" Value="P:System.Web.SiteMap.Enabled" />
<MemberSignature Language="VB.NET" Value="Public Shared ReadOnly Property Enabled As Boolean" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; static property bool Enabled { bool get(); };" />
<MemberSignature Language="F#" Value="member this.Enabled : bool" Usage="System.Web.SiteMap.Enabled" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets a Boolean value indicating if a site map provider is specified in the Web.config file and if the site map provider is enabled.</summary>
<value>
<see langword="true" /> if a site map provider is configured and enabled; otherwise, <see langword="false" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
A default site map configuration is specified that manages the site navigation configuration. You can override this configuration in the Web.config file, should you choose to write your own site map provider.
## Examples
The following code example is a Web.config configuration section that demonstrates how an <xref:System.Web.XmlSiteMapProvider> object is declared to be the default <xref:System.Web.SiteMapProvider> object.
```
<siteMap defaultProvider="MyXmlSiteMapProvider" enabled="true">
<providers>
<add name="MyXmlSiteMapProvider"
description="SiteMap provider that reads in .sitemap XML files."
type="System.Web.XmlSiteMapProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
siteMapFile="my.sitemap" />
</providers>
</siteMap>
```
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="Provider">
<MemberSignature Language="C#" Value="public static System.Web.SiteMapProvider Provider { get; }" />
<MemberSignature Language="ILAsm" Value=".property class System.Web.SiteMapProvider Provider" />
<MemberSignature Language="DocId" Value="P:System.Web.SiteMap.Provider" />
<MemberSignature Language="VB.NET" Value="Public Shared ReadOnly Property Provider As SiteMapProvider" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; static property System::Web::SiteMapProvider ^ Provider { System::Web::SiteMapProvider ^ get(); };" />
<MemberSignature Language="F#" Value="member this.Provider : System.Web.SiteMapProvider" Usage="System.Web.SiteMap.Provider" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Web.SiteMapProvider</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the default <see cref="T:System.Web.SiteMapProvider" /> object for the current site map.</summary>
<value>The default site map provider for the <see cref="T:System.Web.SiteMap" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
By default, the <xref:System.Web.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 <xref:System.Web.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 <xref:System.Web.SiteMapProvider> class. For more information on writing your own provider, see <xref:System.Web.SiteMapProvider>.
## Examples
The following code example demonstrates how to access the default <xref:System.Web.SiteMapProvider> object for the site by using the static <xref:System.Web.SiteMap.Provider%2A> property.
[!code-aspx-csharp[System.Web.SiteMap_2#1](~/samples/snippets/csharp/VS_Snippets_WebNet/System.Web.SiteMap_2/CS/catalog2cs.aspx#1)]
[!code-aspx-vb[System.Web.SiteMap_2#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/System.Web.SiteMap_2/VB/catalog2vb.aspx#1)]
]]></format>
</remarks>
<exception cref="T:System.InvalidOperationException">The site map feature is not enabled.</exception>
<exception cref="T:System.Configuration.ConfigurationErrorsException">The default provider specified in the configuration does not exist.</exception>
<exception cref="T:System.Web.HttpException">The feature is supported only when running in Low trust or higher.</exception>
<altmember cref="P:System.Web.SiteMap.Providers" />
<altmember cref="T:System.Web.SiteMapProvider" />
<altmember cref="T:System.Web.StaticSiteMapProvider" />
</Docs>
</Member>
<Member MemberName="Providers">
<MemberSignature Language="C#" Value="public static System.Web.SiteMapProviderCollection Providers { get; }" />
<MemberSignature Language="ILAsm" Value=".property class System.Web.SiteMapProviderCollection Providers" />
<MemberSignature Language="DocId" Value="P:System.Web.SiteMap.Providers" />
<MemberSignature Language="VB.NET" Value="Public Shared ReadOnly Property Providers As SiteMapProviderCollection" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; static property System::Web::SiteMapProviderCollection ^ Providers { System::Web::SiteMapProviderCollection ^ get(); };" />
<MemberSignature Language="F#" Value="member this.Providers : System.Web.SiteMapProviderCollection" Usage="System.Web.SiteMap.Providers" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Web.SiteMapProviderCollection</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets a read-only collection of named <see cref="T:System.Web.SiteMapProvider" /> objects that are available to the <see cref="T:System.Web.SiteMap" /> class.</summary>
<value>A <see cref="T:System.Web.SiteMapProviderCollection" /> of named <see cref="T:System.Web.SiteMapProvider" /> objects.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The site map providers that are listed in the <xref:System.Web.SiteMap.Providers%2A> collection are those that are specified in the configuration hierarchy to initialize the <xref:System.Web.SiteMap> class. Only the default provider (identified by the <xref:System.Web.SiteMap.Provider%2A> property) is guaranteed to be used by the <xref:System.Web.SiteMap> during initialization; the presence of a provider in the <xref:System.Web.SiteMap.Providers%2A> collection means that it was specified in the configuration and was available during initialization.
## Examples
The following code example demonstrates how to retrieve the <xref:System.Web.SiteMap.Providers%2A> collection from the <xref:System.Web.SiteMap> class, and then iterate through it.
[!code-aspx-csharp[System.Web.SiteMap_2#1](~/samples/snippets/csharp/VS_Snippets_WebNet/System.Web.SiteMap_2/CS/catalog2cs.aspx#1)]
[!code-aspx-vb[System.Web.SiteMap_2#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/System.Web.SiteMap_2/VB/catalog2vb.aspx#1)]
If you have more than just the default provider configured for your site, you will see each provider displayed. For example, if you are using the sample Microsoft Access provider (see <xref:System.Web.StaticSiteMapProvider>), you see the following output:
```
XmlSiteMapProvider System.Web.XmlSiteMapProvider
AccessSiteMapProvider Samples.AspNet.AccessSiteMapProvider
```
]]></format>
</remarks>
<exception cref="T:System.InvalidOperationException">The site map feature is not enabled.</exception>
<exception cref="T:System.Configuration.ConfigurationErrorsException">The default provider specified in the configuration does not exist.</exception>
<exception cref="T:System.Web.HttpException">The feature is supported only when running in Low trust or higher.</exception>
<altmember cref="P:System.Web.SiteMap.Provider" />
<altmember cref="T:System.Web.SiteMapProvider" />
<altmember cref="T:System.Web.StaticSiteMapProvider" />
</Docs>
</Member>
<Member MemberName="RootNode">
<MemberSignature Language="C#" Value="public static System.Web.SiteMapNode RootNode { get; }" />
<MemberSignature Language="ILAsm" Value=".property class System.Web.SiteMapNode RootNode" />
<MemberSignature Language="DocId" Value="P:System.Web.SiteMap.RootNode" />
<MemberSignature Language="VB.NET" Value="Public Shared ReadOnly Property RootNode As SiteMapNode" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; static property System::Web::SiteMapNode ^ RootNode { System::Web::SiteMapNode ^ get(); };" />
<MemberSignature Language="F#" Value="member this.RootNode : System.Web.SiteMapNode" Usage="System.Web.SiteMap.RootNode" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Web.SiteMapNode</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets a <see cref="T:System.Web.SiteMapNode" /> object that represents the top-level page of the navigation structure for the site.</summary>
<value>A <see cref="T:System.Web.SiteMapNode" /> that represents the top-level page of the site's navigation structure; otherwise, <see langword="null" />, if security trimming is enabled and the node cannot be returned to the current user.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.SiteMap> class retrieves the <xref:System.Web.SiteMap.RootNode%2A> property by requesting it from the provider. If there is a provider hierarchy, the <xref:System.Web.SiteMap> class retrieves the root node of the root provider in the hierarchy. To access the root node of the default provider, call the <xref:System.Web.SiteMap.Provider%2A> property, which retrieves both the default provider and its <xref:System.Web.SiteMapProvider.RootNode%2A> property.
The <xref:System.Web.XmlSiteMapProvider> object, which is the default provider for the <xref:System.Web.SiteMap> class, supports only one <xref:System.Web.XmlSiteMapProvider.RootNode%2A>.
If you implement your own <xref:System.Web.SiteMapProvider> class and override the abstract <xref:System.Web.SiteMapProvider.RootNode%2A> property, you must provide your own implementation to track the <xref:System.Web.SiteMapProvider.RootNode%2A> property of the <xref:System.Web.SiteMapNode> instance.
The root node must be visible to all users, by design. If the root node is not visible to all users when security trimming is enabled, accessing the <xref:System.Web.SiteMap.RootNode%2A> property might result in an <xref:System.InvalidOperationException> exception.
## Examples
The following code example demonstrates how to use the <xref:System.Web.SiteMap.RootNode%2A> property to retrieve the <xref:System.Web.SiteMapNode> object that represents the root node of the site, regardless of the current location in the page hierarchy.
[!code-aspx-csharp[System.Web.SiteMap_1#1](~/samples/snippets/csharp/VS_Snippets_WebNet/System.Web.SiteMap_1/CS/catalogcs.aspx#1)]
[!code-aspx-vb[System.Web.SiteMap_1#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/System.Web.SiteMap_1/VB/catalogvb.aspx#1)]
]]></format>
</remarks>
<exception cref="T:System.InvalidOperationException">The site map feature is not enabled.
-or-
The <see cref="P:System.Web.SiteMap.RootNode" /> resolves to <see langword="null" />, which occurs if security trimming is enabled and the root node is not visible to the current user.</exception>
<exception cref="T:System.Configuration.ConfigurationErrorsException">The default provider specified in the configuration does not exist.</exception>
<exception cref="T:System.Web.HttpException">The feature is supported only when running in Low trust or higher.</exception>
<altmember cref="P:System.Web.SiteMap.CurrentNode" />
</Docs>
</Member>
<Member MemberName="SiteMapResolve">
<MemberSignature Language="C#" Value="public static event System.Web.SiteMapResolveEventHandler SiteMapResolve;" />
<MemberSignature Language="ILAsm" Value=".event class System.Web.SiteMapResolveEventHandler SiteMapResolve" />
<MemberSignature Language="DocId" Value="E:System.Web.SiteMap.SiteMapResolve" />
<MemberSignature Language="VB.NET" Value="Public Shared Custom Event SiteMapResolve As SiteMapResolveEventHandler " />
<MemberSignature Language="C++ CLI" Value="public:&#xA; static event System::Web::SiteMapResolveEventHandler ^ SiteMapResolve;" />
<MemberSignature Language="F#" Value="member this.SiteMapResolve : System.Web.SiteMapResolveEventHandler " Usage="member this.SiteMapResolve : System.Web.SiteMapResolveEventHandler " />
<MemberType>Event</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Web.SiteMapResolveEventHandler</ReturnType>
</ReturnValue>
<Docs>
<summary>Occurs when the <see cref="P:System.Web.SiteMap.CurrentNode" /> property is accessed.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Subscribers attach a <xref:System.Web.SiteMapResolveEventHandler> object to the static <xref:System.Web.SiteMap.SiteMapResolve> event to receive notification when the <xref:System.Web.SiteMap.CurrentNode%2A> property is accessed. This enables the user to implement custom logic when creating a <xref:System.Web.SiteMapNode> representation of the currently executing page without requiring a custom provider implementation.
If you subscribe to the <xref:System.Web.SiteMap.SiteMapResolve> event, you also subscribe to the <xref:System.Web.SiteMapProvider.SiteMapResolve> event on the default site map provider.
## Examples
The following code example demonstrates how to handle the <xref:System.Web.SiteMap.SiteMapResolve> event on an ASP.NET Web page to modify the target URLs that are displayed by a site navigation control, such as the <xref:System.Web.UI.WebControls.SiteMapPath> control. In this example, the current page is a post page in an online bulletin board or forum. In order to render more meaningful site navigation, the URLs of the nodes that are displayed by the navigation control are appended with context relevant query strings.
> [!NOTE]
> The ASP.NET site navigation infrastructure guards against infinite recursion, which provides a safeguard and minimizes the security risk that is associated with accessing the <xref:System.Web.SiteMap.CurrentNode%2A> property from within the <xref:System.Web.SiteMapResolveEventHandler> class.
The following code belongs in the Global.asax file. The event handler will be attached only once for the application. The code recognizes whether the page implements the `ISiteMapResolver` interface. If the interface is implemented, the `ExpandForumPaths` function is called.
[!code-csharp[System.Web.SiteMap.SiteMapResolve#1](~/samples/snippets/csharp/VS_Snippets_WebNet/System.Web.SiteMap.SiteMapResolve/CS/sitemapresolve1cs.aspx.cs#1)]
[!code-vb[System.Web.SiteMap.SiteMapResolve#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/System.Web.SiteMap.SiteMapResolve/VB/sitemapresolve1vb.aspx.vb#1)]
The following code defines a separate interface. (In a Web site project, you can put this code in the App_Code folder.) The `ISiteMapResolver` interface defines the `ExpandForumPaths` method.
[!code-csharp[System.Web.SiteMap.SiteMapResolve#2](~/samples/snippets/csharp/VS_Snippets_WebNet/System.Web.SiteMap.SiteMapResolve/CS/sitemapresolve1cs.aspx.cs#2)]
[!code-vb[System.Web.SiteMap.SiteMapResolve#2](~/samples/snippets/visualbasic/VS_Snippets_WebNet/System.Web.SiteMap.SiteMapResolve/VB/sitemapresolve1vb.aspx.vb#2)]
The following code belongs with the page that is at least three nodes deep in the site-map structure. The page implements the `ISiteMapResolver` interface, which enables the `ExpandForumPaths` method to be called.
[!code-aspx-csharp[System.Web.SiteMap.SiteMapResolve#3](~/samples/snippets/csharp/VS_Snippets_WebNet/System.Web.SiteMap.SiteMapResolve/CS/sitemapresolve1cs.aspx#3)]
[!code-aspx-vb[System.Web.SiteMap.SiteMapResolve#3](~/samples/snippets/visualbasic/VS_Snippets_WebNet/System.Web.SiteMap.SiteMapResolve/VB/sitemapresolve1vb.aspx#3)]
]]></format>
</remarks>
<altmember cref="T:System.Web.SiteMapResolveEventHandler" />
<altmember cref="T:System.Web.SiteMapResolveEventArgs" />
</Docs>
</Member>
</Members>
</Type>
You can’t perform that action at this time.