Question

I'm trying to use the Multiple Navigation Paths to a Single Page feature from the MvcSiteMapProvider: https://github.com/maartenba/MvcSiteMapProvider/wiki/Multiple-Navigation-Paths-to-a-Single-Page

And these are the 2 different navigation path that's pointing to the same resource:

<mvcSiteMapNode title="Multi Analysis" controller="Report" action="MultiAnalysis" preservedRouteParameters="id">
<mvcSiteMapNode title="Analysis" controller="Report" action="Analysis" preservedRouteParameters="id,type" type="ma" />
</mvcSiteMapNode>

<mvcSiteMapNode title="Single Analysis" controller="Report" action="SingleAnalysis" preservedRouteParameters="id">
<mvcSiteMapNode title="Analysis" controller="Report" action="Analysis" preservedRouteParameters="id,type" type="sa" />
</mvcSiteMapNode>

But, the breadcrumb is always generated for the top one. Is there something that I'm missing?

Was it helpful?

Solution

Yes, there is something you are missing. A route value and preserved route value cannot be used simultaneously for the same node. I have updated the wiki page because the example configuration was also invalid.

<mvcSiteMapNode title="Multi Analysis" controller="Report" action="MultiAnalysis" preservedRouteParameters="id">
    <mvcSiteMapNode title="Analysis" controller="Report" action="Analysis" preservedRouteParameters="id" type="ma" />
</mvcSiteMapNode>

<mvcSiteMapNode title="Single Analysis" controller="Report" action="SingleAnalysis" preservedRouteParameters="id">
    <mvcSiteMapNode title="Analysis" controller="Report" action="Analysis" preservedRouteParameters="id" type="sa" />
</mvcSiteMapNode>

Note the lack of "type" in the preservedRouteParameters in this case.

Using preservedRouteParameters is for forcing all possible Ids to match a single node by copying the parameter from the current request. This is generally only useful for making the SiteMapPath HTML helper work alongside CRUD operations where you are using a list or table of database records as your main navigation. If you are using the Menu or SiteMap HTML helpers or you want the pages listed in the /sitemap.xml endpoint (the sitemaps XML for search engines), using preservedRouteParameters is not recommended.

I have created a working demo of this feature on my blog: http://www.shiningtreasures.com/post/2013/08/10/mvcsitemapprovider-4-seo-features#canonical-tag

OTHER TIPS

This worked for now:

MvcSiteMapProvider.SiteMaps.GetSiteMap().Clear(); MvcSiteMapProvider.SiteMaps.GetSiteMap().BuildSiteMap();

I guess I'll continue using this until I figure out how the caching works on MvcSiteMapProvider

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top