System.Web.Mvc.HtmlHelper does not contain a definition for MvcSiteMap

I use MvcSiteMapProvider MVC5 with my web application and inside my _Layout.cshtml file, which I use:

@if (Html.MvcSiteMap().SiteMap.CurrentNode != Html.MvcSiteMap().SiteMap.RootNode)
    {
        @Html.MvcSiteMap().SiteMapPath()
    }

But Intellisence throws this error:

System.Web.Mvc.HtmlHelper does not contain a definition for MvcSiteMap

Does anyone know how to solve this problem?

+4
source share
4 answers
@using MvcSiteMapProvider.Web.Html

Fixed by adding this to the top of the view as indicated

@StevenV

+10
source

The namespaces mentioned by @Steven V are automatically added to the file Views\Web.configduring the installation of the NuGet package.

<configuration>
  <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>
</configuration>

Visual Studio intellisense , . @using MvcSiteMapProvider.Web.Html .

+4

, using. @using MvcSiteMapProvider.Web.Html .

, <namespaces> <system.web.webPages.razor> Views\Web.config. Razor using .

+3

MvcSiteMap.

:

Install-Package MvcSiteMapProvider.MVC5

:

@using MvcSiteMapProvider
0
source

Source: https://habr.com/ru/post/1533558/


All Articles