SiteMap::SiteMapResolve Event
Occurs when the CurrentNode property is accessed.
Assembly: System.Web (in System.Web.dll)
Subscribers attach a SiteMapResolveEventHandler object to the static SiteMapResolve event to receive notification when the CurrentNode property is accessed. This enables the user to implement custom logic when creating a SiteMapNode representation of the currently executing page without requiring a custom provider implementation.
If you subscribe to the SiteMapResolve event, you also subscribe to the SiteMapResolve event on the default site map provider.
| Topic | Location |
|---|---|
| How to: Programmatically Modify Site-Map Nodes in Memory | Building ASP .NET Web Applications |
| How to: Programmatically Modify Site-Map Nodes in Memory | Building ASP .NET Web Applications |
The following code example demonstrates how to handle the SiteMapResolve event on an ASP.NET Web page to modify the target URLs that are displayed by a site navigation control, such as the 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 CurrentNode property from within the 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.
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.
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.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Note