Registering the provider

After downloading the MvcSiteMapProvider, you will have to add a reference to the assembly in your project. Also, you will have to register the provider in your Web.config file. Add the following code somewhere in the <system.web> section:

<siteMap defaultProvider="MvcSiteMapProvider" enabled="true"> 
    <clear /> 
    <add name="MvcSiteMapProvider" 
         type="MvcSiteMapProvider.DefaultSiteMapProvider, MvcSiteMapProvider" 
         nodeKeyGenerator="MvcSiteMapProvider.DefaultNodeKeyGenerator, MvcSiteMapProvider" 
         controllerTypeResolver="MvcSiteMapProvider.DefaultControllerTypeResolver, MvcSiteMapProvider" 
         actionMethodParameterResolver="MvcSiteMapProvider.DefaultActionMethodParameterResolver, MvcSiteMapProvider" 
         aclModule="MvcSiteMapProvider.DefaultAclModule, MvcSiteMapProvider" 
         siteMapNodeUrlResolver="MvcSiteMapProvider.DefaultSiteMapNodeUrlResolver, MvcSiteMapProvider"
         siteMapNodeVisibilityProvider="MvcSiteMapProvider.DefaultSiteMapNodeVisibilityProvider, MvcSiteMapProvider"
         siteMapProviderEventHandler="MvcSiteMapProvider.DefaultSiteMapProviderEventHandler, MvcSiteMapProvider"

The following configuration directives can be specified:

Directive Required? Default Description
siteMapFile No ~/Web.sitemap The sitemap XML file to use.
securityTrimmingEnabled No false Use security trimming? When enabled, nodes that the user can not access will not be displayed in any sitemap control.
cacheDuration No 5 Number of minutes the sitemap is cached on the server before refreshing nodes.
enableLocalization No false Enables localization of sitemap nodes.
scanAssembliesForSiteMapNodes No false Scan assemblies for sitemap nodes defined in code?
excludeAssembliesForScan No (empty) Comma-separated list of assemblies that should be skipped when scanAssembliesForSiteMapNodes is enabled. Note that all assemblies in the ~/bin folder except those referenced in the excludeAssembliesForScan attribute are scanned for sitemap nodes.
includeAssembliesForScan No (empty) Comma-separated list of assemblies that should be included when scanAssembliesForSiteMapNodes is enabled. Note that only assemblies referenced in the includeAssembliesForScan attribute are scanned for sitemap nodes.
attributesToIgnore No (empty) Comma-separated list of attributes defined on a sitemap node that should be ignored by the MvcSiteMapProvider.
nodeKeyGenerator No MvcSiteMapProvider.DefaultNodeKeyGenerator, MvcSiteMapProvider Class that will be used to generate sitemap node keys.
controllerTypeResolver No MvcSiteMapProvider.DefaultControllerTypeResolver, MvcSiteMapProvider Class that will be used to resolve the controller for a specific sitemap node.
actionMethodParameterResolver No MvcSiteMapProvider.DefaultActionMethodParameterResolver, MvcSiteMapProvider Class that will be used to determine the list of parameters on a sitemap node.
aclModule No MvcSiteMapProvider.DefaultAclModule, MvcSiteMapProvider Class that will be used to verify security and access rules for sitemap nodes.
siteMapNodeUrlResolver No MvcSiteMapProvider.DefaultSiteMapNodeUrlResolver, MvcSiteMapProvider Class that will be used to generate URLs for sitemap nodes.
siteMapNodeVisibilityProvider No MvcSiteMapProvider.DefaultSiteMapNodeVisibilityProvider, MvcSiteMapProvider Class that will be used to determine visibility for a sitemap node.
siteMapProviderEventHandler No MvcSiteMapProvider.DefaultSiteMapProviderEventHandler Class that can handle specific events, such as when adding a SiteMapNode.

Last edited Dec 2, 2010 at 12:26 PM by maartenba, version 7


maartenba Dec 2, 2010 at 12:34 PM 
Check, I'll ensure both options are available.

sp4ceman Nov 29, 2010 at 1:27 PM 
I agree with plemire, I have about 30 references in my project and only 1 dll I actually need scanned for the sitemap...
Having an include list instead of an exclude list makes sense...

plemire Sep 20, 2010 at 5:53 PM 
It would simpliest to just scan the executing assembly and have a list of assemblies to scan instead. Am I wrong?
Because from my side we have a lot assemblies in our projects, I can't think to omit all but MVC web app dll.

MikeFoden Sep 16, 2010 at 6:44 AM 
It would also be helpful if there was no empty catch statements suppressing errors. Makes it incredibly hard to debug.

arviman Aug 27, 2010 at 8:13 PM 
When scanAssembliesForSiteMapNodes is set to "true" , you **might** run into issues with some third party dll's. You will then have to experiment with the skipAssemblyScanOn attribute. It would be helpful if the DefaultSiteMapProvider.cs file shows the name of the assembly that is causing the exception rather than throwing a generic error.