I changed the default routing in ASP.NET MVC from
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
to
routes.MapRoute(
"Default",
"{controller}/{action}/{id}/{lineNo}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional, lineNo = UrlParameter.Optional });
but now all @Html.ActionLink() calls are rendered to href=””. If I change the route back to default all links are working again.
I used the same route with RC1 and it worked perfectly.
I didn’t find anything in the release docs so I think I’m doing it wrong.
Regards,
Steffen
In a route an optional parameter can appear only at the end. This means that in your route definition the
idparameter cannot be optional. You need to explicitly set it to a value.And when you generate a link you must always provide a value for the id parameter if you want this route to match:
As an alternative you might give a default value to the id parameter:
Now you no longer need to specify it in your links.