0
votes

I have a requirement as for the same controller and action I need to differentiate the parent dynamically. I have a Action called "Note" and a controller called "Note".

Now my requirement is : Home>Note

Home>Index>Note from two different screens.

In my "Note" view I am using @Html.MvcSiteMap().SiteMapPath()

to display the breadcrumb.

In the xml file ,under the Index node,

How to show the breadcrumb dynamiccaly?

1

1 Answers

0
votes

You need to configure each node in the XML, and then the SiteMapPath HTML helper will appear to remember where the user was.

<mvcSiteMapNode title="Home" controller="Home" action="Index">
    <mvcSiteMapNode title="Note" controller="Home" action="Note"/>
</mvcSiteMapNode>

Note that the example you gave is not possible to do because / and /Index map to the same controller action. The whole principle is based on mapping the current request to a unique sitemap node.

The sitemap is static and put in a cache that is shared between all users of the site. If you need it based on dynamic data from a database, you can use one or more custom implementations of DynamicNodeProvider to load the data into the sitemap rather than basing the nodes on XML.