maartenba / MvcSiteMapProvider

An ASP.NET MVC SiteMapProvider implementation for the ASP.NET MVC framework.
Microsoft Public License
539 stars 218 forks source link

Problems with MvcSiteMapProvider_AttributesToIgnore #458

Closed ehaltom closed 7 years ago

ehaltom commented 7 years ago

I'm not sure if this has been asked yet. I couldn't find anything.

Anyhow, I have two custom attributes that I am using in my sitemap:

`

<add key="MvcSiteMapProvider_AttributesToIgnore" value="featuredLinkText" />`

My site uses Areas heavily (I'm not sure that matters though). For the links that utilize these attributes the featuredLinkLocation is hidden as expected, however the featuredLinkText is still defined as a route perameter. In my view model the links are displayed using the typical:

@Html.DisplayFor(m => child)

A node that uses these attributes is:

<mvcSiteMapNode title="About Us" area="About" controller="Home" action="Index" featuredLinkLocation="About" featuredLinkText="Learn about Chemical Bank" >

and the link produced by the above node is: /About/Home?featuredLinkLocation=About

I can't find anything that I've done to explain why this route value is being displayed. From the above can you see anything that I've done wrong?

Thank you so much for your help! Eric

NightOwl888 commented 7 years ago

You just need to define both attributes in the same (singular) MvcSiteMapProvider_AttributesToIgnore element, separated by commas.

<add key="MvcSiteMapProvider_AttributesToIgnore" value="featuredLinkLocation,featuredLinkText" />
ehaltom commented 7 years ago

Ahh, thank you so much. Sorry for such a rookie mistake.

Gua-naiko-che commented 6 years ago

REMARK: if you are using an external DI container, instead of using an appSetting, you should configure this during the DI container configuration, as explained here:

If using an external DI container, this setting can be found on the constructor of the ReservedAttributeNameProvider in a parameter named "attributesToIgnore", which is type IEnumerable<string>.