I am having problems with Html.ActionLink when I have a route that takes more than one parameter. For example, given the following routes defined in the Global.asax file:
routes.MapRoute( "Default", // Route name "{controller}.mvc/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = "" } // Parameter defaults ); routes.MapRoute( "Tagging", "{controller}.mvc/{action}/{tags}", new { controller = "Products", action = "Index", tags = "" } ); routes.MapRoute( "SlugsAfterId", "{controller}.mvc/{action}/{id}/{slug}", new { controller = "Products", action = "Browse", id = "", slug = "" } );
The first two routes work without problems, but when I try to create an action link to the third route using:
<%= Html.ActionLink(Html.Encode(product.Name), "Details", new { id = product.ProductId, slug = Html.Encode(product.Name) }) %>
Am I getting a url like [site-root] / Details / 1? slug = url-slug , whereas I would like the URL to be more like [site-root] / Details / 1 / URL slug
Can anyone see where I'm wrong?
Ian Oxley Apr 09 '09 at 13:33 2009-04-09 13:33
source share