I'm using MVC.SiteMap, with some success. The only problem arises when I have a 3 steps path (or more). Let me share some of the code to clarify my problem:
After some clean-up, this is my route table:
routes.MapRouteWithName(
name: "RealizacaoPesquisa",
url: "RealizacaoPesquisa/{action}/{idPesquisa}/{nrProntuario}/{id}",
defaults: new { controller = "RealizacaoPesquisa", action = "Index", idPesquisa = UrlParameter.Optional, nrProntuario = UrlParameter.Optional, id = UrlParameter.Optional }
);
routes.MapRouteWithName(
name: "Geral",
url: "{controller}/{action}/{id}/{str}",
defaults: new { controller = "Home", action = "Index" }
);
routes.MapRouteWithName(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
And this is my SiteMap XML:
<mvcSiteMapNode title="Realização de Pesquisas" controller="RealizacaoPesquisa" action="Index">
<mvcSiteMapNode title="Participação de Pesquisa" controller="RealizacaoPesquisa" action="Participacao" preservedRouteParameters="idPesquisa">
<mvcSiteMapNode title="Paciente em Pesquisa" controller="RealizacaoPesquisa" action="ParticipacaoPaciente" preservedRouteParameters="idPesquisa;nrProntuario"/>
</mvcSiteMapNode>
</mvcSiteMapNode>
What I expect:
1) When visiting the first page (action = "Index"), it would show Realização de Pesquisas
.
2) When visiting the second page (action = "Participacao", idPesquisa = 2), it would show Realização de Pesquisas > Participação de Pesquisas
.
3) When visiting the third page (action = "ParticipacaoPaciente", idPesquisa = 2, nrProntuario = "032"), it would show Realização de Pesquisas > Participação de Pesquisas > Paciente em Pesquisa
.
Right now, it works except for item 3 (on item 3 it simply won't render anything, taking me to believe that it's not matching any XML node for the siteMap).
EDIT:
Another attempt that rendered the same result, was using the following routes:
routes.MapRouteWithName(
name: "RealizacaoPesquisa_Participacao",
url: "RealizacaoPesquisa/Participacao/{idPesquisa}",
defaults: new { controller = "RealizacaoPesquisa", action = "Participacao" }
);
routes.MapRouteWithName(
name: "RealizacaoPesquisa_Participacao_Paciente",
url: "RealizacaoPesquisa/ParticipacaoPaciente/{idPesquisa}/{nrProntuario}",
defaults: new { controller = "RealizacaoPesquisa", action = "ParticipacaoPaciente" }
);
routes.MapRouteWithName(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
Again, when accessing the first step: http://localhost:61404/RealizacaoPesquisa
everything was good;
when acessing the second step: http://localhost:61404/RealizacaoPesquisa/Participacao/27
everything was still ok;
but when I got to the third step: http://localhost:61404/RealizacaoPesquisa/ParticipacaoPaciente/27/0002642811
No Breadcrumb trail rendered.
Any help?