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"> 
  <providers> 
    <clear /> 
    <add name="MvcSiteMapProvider" 
         type="MvcSiteMapProvider.DefaultSiteMapProvider, MvcSiteMapProvider" 
         siteMapFile="~/Mvc.Sitemap" 
         securityTrimmingEnabled="true" 
         cacheDuration="5"
         enableLocalization="true" 
         scanAssembliesForSiteMapNodes="true" 
         excludeAssembliesForScan="" 
         includeAssembliesForScan="" 
         attributesToIgnore="bling" 
         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"
         /> 
  </providers> 
</siteMap>

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 1:26 PM by maartenba, version 7

Comments

maartenba Dec 2, 2010 at 1:34 PM 
Check http://mvcsitemap.codeplex.com/workitem/5494, I'll ensure both options are available.

sp4ceman Nov 29, 2010 at 2: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 6: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 7: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 9: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.