As the title states, the URL for one of the nodes in the breadcrumb is not correct. I just get a http://localhost/#
Obviously I have something wrong. I have other, similar structures in the sitemap that are working. Can you tell from this whats missing?
I can post more info if needed.
SiteMap :
<mvcSiteMapNode title="ISP" controller="xxx" action="Index">
<mvcSiteMapNode title="PC" action="Details" preservedRouteParameters="pcId">
<mvcSiteMapNode title="SGD" controller="yyy" action="Details" preservedRouteParameters="pcId, yyyId, editable">
<mvcSiteMapNode title="ESGN" controller="yyy" action="Title" preservedRouteParameters="pcId, yyyId, editable" />
</mvcSiteMapNode>
Actions:
[HttpGet]
[Route("xxx/{pcId:int}/yyy/{yyyId:int}/Details/{editable:bool}")]
public virtual ActionResult Details(int pcId, int yyyId, bool editable)
{
[HttpGet]
[Route("xxx/{pcId:int}/yyy/{yyyId:int}/Title")]
public virtual ActionResult Title(int pcId, int yyyId)
{
Route Map:
routes.MapRoute(
name: "xxx",
url: "xxx/{action}/{pcId}",
defaults: new
{
controller = "xxx",
action = "Index",
pcId = UrlParameter.Optional
}
);
Update: When removing the "editable" parameter it started to work. Could there be an issue with more than 2 params? or possibly the type or name of the parameter?
Update following debug advice from NightOwl88:
The urlHelper does generate the correct url's
This is my controller code:
[HttpGet]
[Route("TransactionDetails/File/{fileId:int}")]
public virtual ActionResult Index(int fileId)
{
{
var urlHelper = new UrlHelper(new System.Web.Routing.RequestContext(this.HttpContext, this.RouteData));
var url = urlHelper.Action("Index", "Transaction",
new System.Web.Routing.RouteValueDictionary { { "id", 678 } });
System.Diagnostics.Debug.WriteLine(url);
}
{
var urlHelper = new UrlHelper(new System.Web.Routing.RequestContext(this.HttpContext, this.RouteData));
var url = urlHelper.Action("Index", "File",
new System.Web.Routing.RouteValueDictionary {{"fileId", 123}});
System.Diagnostics.Debug.WriteLine(url);
}
I get: /AdministratorConsole/TransactionDetails/678 and /AdministratorConsole/TransactionDetails/File/123
So the helper is able to generate a url for me but MvcSiteMapProvider is still not happy.
SiteMap is:
<mvcSiteMapNode title="Transaction Log" controller="TransactionLog" action="Index">
<mvcSiteMapNode title="Transaction Details" controller="Transaction" action="Index" preservedRouteParameters="id">
<mvcSiteMapNode title="File Details" controller="File" action="Index" preservedRouteParameters="id, fileId"> <!--TODO link back to parent not working-->