I want to be able to map a route using a URL that doesn't conform to the {controller}/{action}/{id} format. The mapping looks like:
routes.CreateArea("Root", "MyApp.Web.Controllers",
routes.MapRoute("Category-List", "Category/{category}",
new { controller = "Category", action = "List" }),
routes.MapRoute("Default", "{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = "" })
);
Where I have a CategoryController
with an action List(string category)
.
I was hoping to be able to use this in my view:
<%= Html.ActionLink<CategoryController>(
c => c.List(category.UrlFriendlyName),
category.Name)%>
(line breaks added for readability)
All this produces is a link with href=""
. Removing the route from the "Root" area produces the correct result. Is it possible to use this type of mapping with the generic ActionLink helper or do I have to resort to RouteLink or something similar with hard coded values?
I also tried the following with no success:
<%= Html.ActionLink(category.Name, "List", "Category",
new { category = category.UrlFriendlyName }) %>