I am using MvcSiteMapProvider MVC5 with my web application and inside of my _Layout.cshtml file I am using:
我正在使用MvcSiteMapProvider MVC5和我的Web应用程序,并在我使用的_Layout.cshtml文件中:
@if (Html.MvcSiteMap().SiteMap.CurrentNode != Html.MvcSiteMap().SiteMap.RootNode)
{
@Html.MvcSiteMap().SiteMapPath()
}
But the Intellisence is throwing this error:
但Intellisence抛出了这个错误:
System.Web.Mvc.HtmlHelper does not contain a definition for MvcSiteMap
Does anyone know how to fix this problem?
有谁知道如何解决这个问题?
4 个解决方案
#1
11
@using MvcSiteMapProvider.Web.Html
Fixed by adding this to the top of the view as said by
通过将其添加到视图的顶部来修复
@StevenV
#2
4
The namespaces that @Steven V mentioned are automatically added to the Views\Web.config
file during installation of the NuGet package.
@Steven V提到的命名空间在安装NuGet包期间会自动添加到Views \ Web.config文件中。
<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>
However, Visual Studio intellisense requires a recompile of the project before it picks them up. There is no need to add a @using MvcSiteMapProvider.Web.Html
statement to the view.
但是,Visual Studio intellisense需要在拾取项目之前重新编译项目。无需在视图中添加@using MvcSiteMapProvider.Web.Html语句。
#3
3
I think you're missing a using statement. Try adding @using MvcSiteMapProvider.Web.Html
to the top of the view.
我想你错过了一个使用声明。尝试将@using MvcSiteMapProvider.Web.Html添加到视图的顶部。
If you're going to use it often, think about adding the namespace to the <namespaces>
section under <system.web.webPages.razor>
in the Views\Web.config. That will make it available on all Razor views inside that folder without the need of an using
statement on each individual view.
如果您要经常使用它,请考虑将名称空间添加到Views \ Web.config中
#4
0
You need to install the MvcSiteMap Provider.
您需要安装MvcSiteMap Provider。
You can do this from the Package Manger Console with the following command:
您可以使用以下命令从Package Manger Console执行此操作:
Install-Package MvcSiteMapProvider.MVC5
Then at the top of the razor add:
然后在剃刀顶部添加:
@using MvcSiteMapProvider
#1
11
@using MvcSiteMapProvider.Web.Html
Fixed by adding this to the top of the view as said by
通过将其添加到视图的顶部来修复
@StevenV
#2
4
The namespaces that @Steven V mentioned are automatically added to the Views\Web.config
file during installation of the NuGet package.
@Steven V提到的命名空间在安装NuGet包期间会自动添加到Views \ Web.config文件中。
<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>
However, Visual Studio intellisense requires a recompile of the project before it picks them up. There is no need to add a @using MvcSiteMapProvider.Web.Html
statement to the view.
但是,Visual Studio intellisense需要在拾取项目之前重新编译项目。无需在视图中添加@using MvcSiteMapProvider.Web.Html语句。
#3
3
I think you're missing a using statement. Try adding @using MvcSiteMapProvider.Web.Html
to the top of the view.
我想你错过了一个使用声明。尝试将@using MvcSiteMapProvider.Web.Html添加到视图的顶部。
If you're going to use it often, think about adding the namespace to the <namespaces>
section under <system.web.webPages.razor>
in the Views\Web.config. That will make it available on all Razor views inside that folder without the need of an using
statement on each individual view.
如果您要经常使用它,请考虑将名称空间添加到Views \ Web.config中
#4
0
You need to install the MvcSiteMap Provider.
您需要安装MvcSiteMap Provider。
You can do this from the Package Manger Console with the following command:
您可以使用以下命令从Package Manger Console执行此操作:
Install-Package MvcSiteMapProvider.MVC5
Then at the top of the razor add:
然后在剃刀顶部添加:
@using MvcSiteMapProvider