作为查询字符串附加的属性
Attribute being appending as query string
我正在尝试拥有多个 attributesToIgnore
,所以我将其配置为:
attributesToIgnore="hideOnStandard, hideFormatting"
和我的 Mvc.sitemap
:
<mvcSiteMapNode title="Filters" controller="Parameterized">
<mvcSiteMapNode title="Filters" controller="Parameterized" action="Index"/>
<mvcSiteMapNode title="Output" controller="Parameterized" action="Output" preservedRouteParameters="id" hideOnStandard="true"/>
<mvcSiteMapNode title="Formatting" controller="Parameterized" action="Formatting" preservedRouteParameters="id" hideFormatting="true" />
</mvcSiteMapNode>
但是,它将 hideFormatting="true"
附加到锚标记的查询字符串中,例如:
<a href="/Home/Reports/Formatting/29119?hideFormatting=true">Formatting</a>
我怎样才能真正执行我想做的事情?我试图以不同的方式分隔 attributesToIgnore
,但除此之外,我不太确定还能怎么做。我 真的 不想使用 jQuery 或其他东西来去除查询字符串。
编辑
我怎么知道要渲染什么:
@model MvcSiteMapProvider.Web.Html.Models.MenuHelperModel
@using System.Web.Mvc.Html
@using MvcSiteMapProvider.Web.Html.Models
<ul class="navProgress">
@foreach (var node in Model.Nodes)
{
if (!(node.MetaAttributes.Keys.Contains("hideOnStandard") && TempData["IsStandard"] != null && ((bool)TempData["IsStandard"])))
{
if (!(node.MetaAttributes.Keys.Contains("hideFormatting") && TempData["hideFormatting"] != null && ((bool)TempData["hideFormatting"])))
{
<li @(node.IsCurrentNode ? "class=active" : "")>
@Html.DisplayFor(m => node)
@if (node.Children.Any())
{
@Html.DisplayFor(m => node.Children)
}
</li>
}
}
}
</ul>
根据 MvcSiteMapProvider v3 documentation,attributesToIgnore
应添加到 web.config
的 <siteMap>
部分。
<siteMap>
<providers>
<add name="MvcSiteMapProvider" type="MvcSiteMapProvider.DefaultSiteMapProvider, MvcSiteMapProvider"
siteMapFile="~/Mvc.Sitemap"
securityTrimmingEnabled="true"
cacheDuration="5"
enableLocalization="true"
scanAssembliesForSiteMapNodes="true"
excludeAssembliesForScan=""
includeAssembliesForScan=""
attributesToIgnore="hideOnStandard,hideFormatting"
nodeKeyGenerator="MvcSiteMapProvider.DefaultNodeKeyGenerator, MvcSiteMapProvider"
controllerTypeResolver="MvcSiteMapProvider.DefaultControllerTypeResolver, MvcSiteMapProvider"
actionMethodParameterResolver="MvcSiteMapProvider.DefaultActionMethodParameterResolver, MvcSiteMapProvider"
aclModule="MvcSiteMapProvider.DefaultAclModule, MvcSiteMapProvider"
routeMethod=""
siteMapNodeUrlResolver="MvcSiteMapProvider.DefaultSiteMapNodeUrlResolver, MvcSiteMapProvider"
siteMapNodeVisibilityProvider="MvcSiteMapProvider.DefaultSiteMapNodeVisibilityProvider, MvcSiteMapProvider"
siteMapProviderEventHandler="MvcSiteMapProvider.DefaultSiteMapProviderEventHandler, MvcSiteMapProvider" />
</providers>
</siteMap>
I believe in v3.x, you also had to ensure there is not a space after the comma or it won't match the attribute correctly.
使用:
attributesToIgnore="hideOnStandard,hideFormatting"
而不是:
attributesToIgnore="hideOnStandard, hideFormatting"
我正在尝试拥有多个 attributesToIgnore
,所以我将其配置为:
attributesToIgnore="hideOnStandard, hideFormatting"
和我的 Mvc.sitemap
:
<mvcSiteMapNode title="Filters" controller="Parameterized">
<mvcSiteMapNode title="Filters" controller="Parameterized" action="Index"/>
<mvcSiteMapNode title="Output" controller="Parameterized" action="Output" preservedRouteParameters="id" hideOnStandard="true"/>
<mvcSiteMapNode title="Formatting" controller="Parameterized" action="Formatting" preservedRouteParameters="id" hideFormatting="true" />
</mvcSiteMapNode>
但是,它将 hideFormatting="true"
附加到锚标记的查询字符串中,例如:
<a href="/Home/Reports/Formatting/29119?hideFormatting=true">Formatting</a>
我怎样才能真正执行我想做的事情?我试图以不同的方式分隔 attributesToIgnore
,但除此之外,我不太确定还能怎么做。我 真的 不想使用 jQuery 或其他东西来去除查询字符串。
编辑
我怎么知道要渲染什么:
@model MvcSiteMapProvider.Web.Html.Models.MenuHelperModel
@using System.Web.Mvc.Html
@using MvcSiteMapProvider.Web.Html.Models
<ul class="navProgress">
@foreach (var node in Model.Nodes)
{
if (!(node.MetaAttributes.Keys.Contains("hideOnStandard") && TempData["IsStandard"] != null && ((bool)TempData["IsStandard"])))
{
if (!(node.MetaAttributes.Keys.Contains("hideFormatting") && TempData["hideFormatting"] != null && ((bool)TempData["hideFormatting"])))
{
<li @(node.IsCurrentNode ? "class=active" : "")>
@Html.DisplayFor(m => node)
@if (node.Children.Any())
{
@Html.DisplayFor(m => node.Children)
}
</li>
}
}
}
</ul>
根据 MvcSiteMapProvider v3 documentation,attributesToIgnore
应添加到 web.config
的 <siteMap>
部分。
<siteMap>
<providers>
<add name="MvcSiteMapProvider" type="MvcSiteMapProvider.DefaultSiteMapProvider, MvcSiteMapProvider"
siteMapFile="~/Mvc.Sitemap"
securityTrimmingEnabled="true"
cacheDuration="5"
enableLocalization="true"
scanAssembliesForSiteMapNodes="true"
excludeAssembliesForScan=""
includeAssembliesForScan=""
attributesToIgnore="hideOnStandard,hideFormatting"
nodeKeyGenerator="MvcSiteMapProvider.DefaultNodeKeyGenerator, MvcSiteMapProvider"
controllerTypeResolver="MvcSiteMapProvider.DefaultControllerTypeResolver, MvcSiteMapProvider"
actionMethodParameterResolver="MvcSiteMapProvider.DefaultActionMethodParameterResolver, MvcSiteMapProvider"
aclModule="MvcSiteMapProvider.DefaultAclModule, MvcSiteMapProvider"
routeMethod=""
siteMapNodeUrlResolver="MvcSiteMapProvider.DefaultSiteMapNodeUrlResolver, MvcSiteMapProvider"
siteMapNodeVisibilityProvider="MvcSiteMapProvider.DefaultSiteMapNodeVisibilityProvider, MvcSiteMapProvider"
siteMapProviderEventHandler="MvcSiteMapProvider.DefaultSiteMapProviderEventHandler, MvcSiteMapProvider" />
</providers>
</siteMap>
I believe in v3.x, you also had to ensure there is not a space after the comma or it won't match the attribute correctly.
使用:
attributesToIgnore="hideOnStandard,hideFormatting"
而不是:
attributesToIgnore="hideOnStandard, hideFormatting"