HtmlHelper ignores templates

Apr 26, 2011 at 2:22 PM

First things first, thank you for the wonderful MvcSiteMapProvider.

According to HtmlHelper functions documentation (, I've tried to change the template, but it seems that HtmlHelper completely ignores the templates. 

I've already read  this discussion:

I've tried to put my custom template in both ~/Views/DisplayTemplates/MenuHelperModel.cshtml and ~/Views/Shared/DisplayTemplates/MenuHelperModel.cshtml

I'm not sure if @Html.MvcSiteMap().Menu() is enough or I should use:

@Html.MvcSiteMap().Menu(string templateName, int StartingNodeLevel, int maxDepth, [bool allowForwardSearch=false], [bool drillDownToCurrent=false])

* Also I'm not sure what "templateName" is!

I use version 3.0.0 with ASP.NET 4 MVC 3 and Razor.

Any solution?

Apr 27, 2011 at 6:16 AM

@Html.MvcSiteMap().Menu() should work. Are you using the NuGet package? If so, there's something missing (will be updated soon):


Registering MvcSiteMapProvider HtmlHelper functions with Razor ViewEngine

In the Web.config file under the Views folder, add the following under the <system.web.webPages.razor> element:

  <! -- ... -->
  <pages pageBaseType="System.Web.Mvc.WebViewPage">
      <! -- ... --> 
      <add namespace="MvcSiteMapProvider.Web.Html" /> 
      <add namespace="MvcSiteMapProvider.Web.Html.Models" /> 


Aug 2, 2011 at 11:11 AM

I have the namespace declarations already but the templates are still ignored for me.

Aug 2, 2011 at 11:30 AM

I just discovered that the MvcSiteMapProvider will use the ASCX file if it is there.  Rename or delete the ASCX file and notice that the provider uses the razor (CSHTML) file.