If you are coming from MvcSiteMapProvider version 3 you will notice some changes in version 4. One of the key changes in version 4 is using app setting key/values instead of the SiteMap node. To learn more about new features in version 4 click here.

Implementing a visibility provider in version 4 is simple. It requires a couple small steps:

  1. Creating a class and derive it from “SiteMapNodeVisibilityProviderBase”.
  2. Add a setting to your web.config file.
  3. Update the site map file.

 

Creating our visibility class

Configuring web.config

Take caution and matchup your namespaces and classes correctly with the sample code I provided. Add a new app setting key/value:

<add key="MvcSiteMapProvider_DefaultSiteMapNodeVisibiltyProvider" value="MyCompany.Web.MyCompanySiteMapVisibilityProvider, MyCompany.Web" />

Making adjustments to sitemap

Finally we are going to make some adjustments to our sitemap file, use the following node as an example, take note of the visibility attribute:

<mvcSiteMapNode title="My Page I want to hide" controller="Home" action="HidePage" visibility="false">

 

I hope this helps, if you have any questions please contact me on twitter: @tekguy