您好我想使用带有 2 个不同站点地图的 asp.net MVCSiteMapProvider v4,一个用于主站点,一个用于管理区域。我做了一些搜索,发现您需要在 web.config 中插入它:
<siteMap defaultProvider="AppSiteMapProvider" enabled="true">
<providers>
<clear />
<add name="AppSiteMapProvider" type="MvcSiteMapProvider.DefaultSiteMapProvider,
MvcSiteMapProvider" siteMapFile="~/Mvc2.sitemap"
securityTrimmingEnabled="true" cacheDuration="5"
enableLocalization="true" scanAssembliesForSiteMapNodes="true"
includeAssembliesForScan="" excludeAssembliesForScan=""
attributesToIgnore="visibility"
nodeKeyGenerator="MvcSiteMapProvider.DefaultNodeKeyGenerator,
MvcSiteMapProvider"
controllerTypeResolver="MvcSiteMapProvider.DefaultControllerTypeResolver,
MvcSiteMapProvider"
actionMethodParameterResolver="MvcSiteMapProvider.DefaultActionMethodParameterResolver,
MvcSiteMapProvider" aclModule="MvcSiteMapProvider.DefaultAclModule,
MvcSiteMapProvider"
siteMapNodeUrlResolver="MvcSiteMapProvider.DefaultSiteMapNodeUrlResolver, MvcSiteMapProvider"
siteMapNodeVisibilityProvider="MvcSiteMapProvider.DefaultSiteMapNodeVisibilityProvider, MvcSiteMapProvider"
siteMapProviderEventHandler="MvcSiteMapProvider.DefaultSiteMapProviderEventHandler, MvcSiteMapProvider" />
<add name="AdminSiteMapProvider" type="MvcSiteMapProvider.DefaultSiteMapProvider,
MvcSiteMapProvider" siteMapFile="~/Areas/Admin/Mvc.Sitemap"
securityTrimmingEnabled="true" cacheDuration="5" enableLocalization="true"
scanAssembliesForSiteMapNodes="true" includeAssembliesForScan=""
excludeAssembliesForScan="" attributesToIgnore="visibility"
nodeKeyGenerator="MvcSiteMapProvider.DefaultNodeKeyGenerator, MvcSiteMapProvider"
controllerTypeResolver="MvcSiteMapProvider.DefaultControllerTypeResolver, MvcSiteMapProvider"
actionMethodParameterResolver="MvcSiteMapProvider.DefaultActionMethodParameterResolver,
MvcSiteMapProvider" aclModule="MvcSiteMapProvider.DefaultAclModule, MvcSiteMapProvider"
siteMapNodeUrlResolver="MvcSiteMapProvider.DefaultSiteMapNodeUrlResolver, MvcSiteMapProvider"
siteMapNodeVisibilityProvider="MvcSiteMapProvider.DefaultSiteMapNodeVisibilityProvider, MvcSiteMapProvider"
siteMapProviderEventHandler="MvcSiteMapProvider.DefaultSiteMapProviderEventHandler, MvcSiteMapProvider" />
</providers>
</siteMap>
然后使用
@Html.MvcSiteMap("AdminSiteMapProvider").Menu()
但它不起作用。有人有同样的问题吗??????顺便说一句,错误是:
Could not find file 'P:\MVCTest\MvcSite1\MvcSite1\Mvc.sitemap'.
就像他们只是忽略了 web.config