Implementing VisibilityProvider in MvcSiteMapProvider

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

By |January 9th, 2014|Coding|0 Comments

Could not load file or assembly ‘System.Web.Mvc’

So I published my first MVC project today to my production server. I got this error:

Parser Error Message: Could not load file or assembly ‘System.Web.Mvc, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35’ or one of its dependencies. The system cannot find the file specified.

After some quick research the solution was simple and obvious. Upon publishing the assemebly System.Web.Mvc.dll was not placed into the bin folder. We have two options:

1). Find the DLL in your project folder and copy it to the production server
2). Set the “Copy Local” property on the DLL to TRUE. This can be done by browsing to the References folder in the Web project, clicking on System.Web.Mvc and pulling up the properties, select the property “Copy Local” and make sure its set to True. Perform another publish and you should be ready to go!

By |January 4th, 2011|Coding, Uncategorized|0 Comments