This project is read-only.

How to: Add Module Pages to the Site Map

You can use a business module to encapsulate a set of concerns of your application and independently deploy them to your applications. Business modules register site map nodes with the ISiteMapBuilderService to expose their features to the Web site. ISiteMapBuilderService is a service that uses the site map nodes of each module loaded in the application to create the full site map. The custom site map data provider ModuleSiteMapProvider consumes the site map. You can use any ASP.NET navigation control (for example, the Menu control or the TreeView control) to display the site map in your Web site user interface.
This topic describes how to add module pages to the site map.


This topic assumes you have an existing Web client solution with a business module. For information about how to create a Web client solution, see How to: Create a Web Client Solution. For information about how to create a business module, see How to: Create a Business Module.


The following procedure describes how to module pages to the site map.

To add pages to the site map
  • Locate the RegisterSiteMapInformation method of the module initialization class for your module. (The Add Business Module recipe generates the module initialization class with an empty RegisterSiteMapInformation method.)
  • In this method, create the site map nodes for your module. To create a site map node, instantiate the SiteMapNodeInfo class as shown in the following code.
SiteMapNodeInfo moduleNode = new SiteMapNodeInfo("Customers", "~/Customers/ApproveCustomerView.aspx", "Approve Customer"); 

The ModuleSiteMapProvider converts SiteMapNodeInfo objects into System.Web.SiteMapNode objects so they can be consumed by ASP.NET navigation controls. This requires the constructor of the SiteMapNodeInfo class to have the same overloads as the System.Web.SiteMapNode class (except for the provider parameter which is implicitly defined). It also means you can construct SiteMapNodeInfo objects in the same way that you construct System.Web.SiteMapNode objects.
  • Use the AddNode method to register the site map nodes with the ISiteMapBuilderService. The AddNode method includes the overloads that you can use to specify the following arguments:
    • The parent node of a node. You use this overload to build a hierarchy of site map nodes.
    • The preferred display order. You use this overload to specify the preferred position of the site map node in the site map.
    • An authorization rule. You use this overload to control whether a site map node can be viewed by the current user. The ModuleSiteMapProvider class uses the IAuthorizationService service to implement the IsAccessibleToUser method.
The following code demonstrates the overloads of the AddNode method.


// Specify the parent node
siteMapBuilderService.AddNode(moduleNode, parentNode);

// Specify the preferred display order
siteMapBuilderService.AddNode(moduleNode, 100);

// Specify the authorization rule
siteMapBuilderService.AddNode(moduleNode, “AllowViewModule1”); 


The module's site map nodes appear in the Web site user interface (this assumes your Web site contains a control, such as a TreeView, that consumes and displays the site map data).

Next Steps

After you add module pages to the site map, a typical task to perform next is to define authorization rules. If you use authorization rules to control whether a site map node can be viewed by the current user, you must define the authorization rules for your application. The rules typically include the roles or users that are associated with the rules. If you use the EnterpriseLibraryAuthorizationService (the default IAuthorizationService implementation), you define the authorization rules in the securityConfiguration section of your application configuration file.

Last edited Nov 20, 2007 at 2:28 PM by ejadib, version 2


No comments yet.