Question

I have a SiteMapNode hanging off the main Dashboard SiteMapNode:

    <mvcSiteMapNode title="Dashboard" controller="DB" action="Index">
      <mvcSiteMapNode title="Company Users" controller="SGAccount" action="ListSOU" preservedRouteParameters="OrgId,caller"/>

The breadcrumb produced by the above is: "Dashboard > Company Users"

I want to also reference this, and get "Dashboard > Yours Sub > Company Users"

    <mvcSiteMapNode title="Dashboard" controller="DB" action="Index">

      <mvcSiteMapNode title="Your Sub" controller="SOU" action="ListSub">
         <mvcSiteMapNode title="Company Users" controller="SGAccount" action="ListSOU" preservedRouteParameters="OrgId,caller"/>
     </mvcSiteMapNode> 

    </mvcSiteMapNode> 

However I still get : "Dashboard > Company Users"

I suspect it is still pattern matching against the first SiteMapNode.

How can I ensure that the correct SiteMapNode is used, and thus produces the correct BreadCrumb Trail. Incidentally the Controller and Action is the same, so I am not sure how useful Action Attributes will be?

Many thanks.

Was it helpful?

Solution

The guiding principle of the sitemap is that each node must be unique. Therefore, you cannot have 1 node in 2 different places because the match will always be the first node.

However, you can create 2 different nodes that point to the same resource, each with its own unique route (and unique URL). You just need to ensure there is more than one route that reaches your action. There is a document describing how to do that here: https://github.com/maartenba/MvcSiteMapProvider/wiki/Multiple-Navigation-Paths-to-a-Single-Page

Also, there is a working example on my blog: http://www.shiningtreasures.com/post/2013/08/10/mvcsitemapprovider-4-seo-features#canonical-tag

That just uses the default route with another querystring parameter, but you could also add an additional route to the same controller action in your MVC application to get the same result.

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