I'm trying to have multiple attributesToIgnore
, so I configured it like:
attributesToIgnore="hideOnStandard, hideFormatting"
and my 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>
However, it appends the hideFormatting="true"
to the query string for the anchor tag, like:
<a href="/Home/Reports/Formatting/29119?hideFormatting=true">Formatting</a>
How can I actually perform what I am trying to do? I've tried to delimit the attributesToIgnore
differently, but other than that I'm not quite sure how else to go about it. I really don't want to use jQuery or something to strip the query string off.
How I know what to render :
@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>
As per the MvcSiteMapProvider v3 documentation , attributesToIgnore
should be added to the <siteMap>
section of web.config
.
<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.
Use:
attributesToIgnore="hideOnStandard,hideFormatting"
Rather than:
attributesToIgnore="hideOnStandard, hideFormatting"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.