I am using MVC3, C#4, Razor, MvcSiteMapProvider V4.
I am trying to bind my MvcSiteMapNodes in my mvc.sitemap file explicitly to my routes in my global.asa. But it does not seem to work. No doubt I have omitted something.
my routes in global.asa:
routes.MapRoute("Report", "Report/{ClientId}", new { controller = "Report", action = "Index", ClientId = UrlParameter.Optional });
routes.MapRoute("Report_Section", "Report/{ClientId}/Section/{ReportId}", new { controller = "Section", action = "FilterByReport", ReportId = UrlParameter.Optional });
Part of my mvc.sitemap:
<mvcSiteMapNode title="Reports" controller="Report" action="Index" preservedRouteParameters="ClientId" route="Report">
<mvcSiteMapNode title="Sections" route="Report_Section">
So my 2 URLs are:
Reports Route:
Report/10
Reports_Sections Route:
Report/10/Section/100
I am not getting the recognition on the second route, and therefore the breadcrumb trail does not appear on the relevant page. I had hoped just by specifying the "route" attribute in mvc.sitemap, the mvcSiteMapProvider would bind the two.
Thoughts. Where have I gone wrong?
Many thanks
EDIT:
It seems that I need to specify the "controller" and "action" in "mvc.sitemap" and "route" on its own will not work.
<mvcSiteMapNode title="Sections" controller="Section" action="FilterByReport" route="Report_Section" preservedRouteParameters="ClientId,ReportId">