0
votes

I am using MvcSiteMapProvider only for displaying BreadCrumb on my side. I am having multiple masters (specifically, 27) in my application with CRUD screens. Each master has a controller, with Index, Create, Edit, Detail and Delete action. I don't want in detail breadcrumb for each action, only controller is enough for me. E.g
1. Organisation Setup:
- Department Group
* Department
- Project Group
* Project
- etc Groups

Now, when I configure MvcSiteMapProvider xml sitemap, i need something like this

<mvcSiteMapNode title="Department Group" controller="DeptGrp" action="*"> 
    <mvcSiteMapNode title="Department" controller="department" action="*" /> 
</mvcSiteMapNode>
<mvcSiteMapNode title="Project Group" controller="PrjGrp" action="*"> 
    <mvcSiteMapNode title="Project" controller="project" action="*" /> 
</mvcSiteMapNode>

But, MvcSiteMapProvider does allow action name to "*". It needs to be specific. How do I configure map just base on controller, when action does have play any significance in node selection, in sitemaphelper to display breadcrumb?

I use this to display breadcrumb

@Html.MvcSiteMap().SiteMapPath()
1

1 Answers

1
votes

No, it is not possible to match more than one action with a single node.

The idea is that you need to create a hierarchy in the MvcSiteMapProvider configuration for navigation because MVC doesn't automatically provide one. Note that you can use visibility providers to hide any nodes that you don't want shown in the SiteMapPath.

If you have a specific convention you are following, you could use either a dynamic node provider or implement ISiteMapNodeProvider and use Reflection to discover your actions so there is a node added for each one automatically.

Another option is to use a single action on each controller with a parameter. In that case, you can use preservedRouteParameters to force a match on every value for that parameter and then you will only need a single node for the entire controller.

But whatever the case, you need a node for each action.