System.Web.Mvc.HtmlHelper<dynamic>' does not contain a definition for 'MvcSiteMap'

Dec 30, 2010 at 1:11 PM

Hi,

I am using ASP.NET MVC 3 RC 2 and I am having issues using this site map provider.  I have added the reference to the DLL.  I have the following defined:

Web.sitemap:

<?xml version="1.0" encoding="utf-8" ?>
<mvcSiteMap xmlns="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-2.0" enableLocalization="true">
   <mvcSiteMapNode title="Online Recognition System" action="Index" controller="Home">
      <mvcSiteMapNode title="Maintain News" action="Index" controller="News" />
   </mvcSiteMapNode>
</mvcSiteMap>

 

Web.config:

<pages>
   <namespaces>
      ...
      <add namespace="MvcSiteMapProvider.Web.Html" />
   </namespaces>
</pages>

 

 

<siteMap defaultProvider="MvcSiteMapProvider" enabled="true">
   <providers>
      <clear/>
      <add
         name="MvcSiteMapProvider"
         type="MvcSiteMapProvider.DefaultSiteMapProvider, MvcSiteMapProvider"
         siteMapFile="~/Web.Sitemap"/>
   </providers>
</siteMap>

Web layout:
<div id="breadcrumbs">@Html.MvcSiteMap().SiteMapPath()</div>

I keep on getting the following error:

System.Web.Mvc.HtmlHelper<dynamic>' does not contain a definition for 'MvcSiteMap' and no extension method 'MvcSiteMap' accepting a first argument of type 'System.Web.Mvc.HtmlHelper<dynamic>' could be found (are you missing a using directive or an assembly reference?)

Thanks
Brendan

 

Coordinator
Jan 6, 2011 at 7:59 AM

This probably has to do with the way Razor is configured. I've updated the documentation accordingly:

Registering MvcSiteMapProvider HtmlHelper functions with Webforms ViewEngine

In the root Web.config file, add the following under the <pages> element:

<pages> 
    <controls> 
        <! -- ... --> 
    </controls> 
    <namespaces> 
        <! -- ... --> 
        <add namespace="MvcSiteMapProvider.Web.Html" /> 
        <add namespace="MvcSiteMapProvider.Web.Html.Models" /> 
    </namespaces> 
</pages>

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:

<system.web.webPages.razor>
  <! -- ... -->
  <pages pageBaseType="System.Web.Mvc.WebViewPage">
    <namespaces>
      <! -- ... --> 
      <add namespace="MvcSiteMapProvider.Web.Html" /> 
      <add namespace="MvcSiteMapProvider.Web.Html.Models" /> 
    </namespaces>
  </pages>
</system.web.webPages.razor>
Jul 21, 2011 at 10:09 PM

I've done the above corrections, and it still doesn't work.

Someone else in StackOverFlow website said that the MvcSiteMapProvider will not work with strongly typed collections (which is what I'm using in this project).

In another project, I'm not using strongly typed collections and it works fine.

Please let me know if and when I can implement a work-around for this or when you update the dll.

Thanks,

Bill..

Coordinator
Jul 25, 2011 at 11:18 AM

Can you share a sample? I'll see if I can fix this.

Aug 5, 2011 at 7:10 PM
mvcsitemapprovider does not work with a Telerik menu extension.

I have two projects. One with a MS out of the box and a simple list item menu which works. The other one is a Telerik menu which doesn't work.

Thank You,

Bill Yeager

Microsoft MCP.Net

CompTIA Security+

BrainBench BCIP, .Net Programmer, Computer Programmer, Mainframe Programmer





From: [email removed]
To: [email removed]
Date: Mon, 25 Jul 2011 03:18:48 -0700
Subject: Re: System.Web.Mvc.HtmlHelper<dynamic>' does not contain a definition for 'MvcSiteMap' [mvcsitemap:239999]

From: maartenba
Can you share a sample? I'll see if I can fix this.
Read the full discussion online.
To add a post to this discussion, reply to this email (mvcsitemap@discussions.codeplex.com)
To start a new discussion for this project, email mvcsitemap@discussions.codeplex.com
You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.
Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com
Coordinator
Aug 26, 2011 at 1:43 PM

Telerik does not use ASP.NET sitemaps apparently, so MvcSiteMapProvider is not directly compatible without plumbing.