Search code examples
asp.net-mvc-3razorhtml-helpermvcsitemapprovider

Problem with MvcSiteMapProvider 3.0 with ASP.NET MVC3 with Razor


I am having trouble getting MvcSiteMapProvider to work. I have read the documentation on codeplex, and set it up just like they show.

I have referenced the MvcSiteMapProvider.dll to my web project.

The problem I'm having is that I cant access @Html.MvcSiteMap() at all. The .MvcSiteMap is missing in the HtmlHelper.

Any suggestions ?


Solution

  • Did you add references to web.config? As is described here.

    Edit: Ok I downloaded it, made new MVC 3 project, referenced the dll and added the namespaces into two configs (one root and one in /Views/ folder) and I have it working. image.

    At first I did a mistake in doing Ctrl+C -> Ctrl+V when adding those namespaces into web configs. I selected whole codeblocks they provide and tried to paste them into web configs. Which was of course wrong. You have to select only those two lines

    <add namespace="MvcSiteMapProvider.Web.Html" /> 
    <add namespace="MvcSiteMapProvider.Web.Html.Models" />
    

    And add them into element. Maybe you did it right, but I followed their steps and I got it working so you would have to provide your code if you did the same and it's not working for you.

    Or if you won't get it working, then try to do what I did. Make new mvc project, add the sitemap, add it into config and check, if you are getting it in your View.