I've been trying to get a couple of custom routes working with no luck. I have two pages for my automotive app. The first page shows a list of vehicles. When the user clicks the links generated on this page it takes them to the product list page. The problem is this page doesn't generate the links properly.
Here is the routes:
routes.MapRoute(
"Select_Vehicle",
"Select_Vehicle/{id}/{make}",
new { controller = "Select_Vehicle", action = "Index", id = UrlParameter.Optional, make = UrlParameter.Optional });
routes.MapRoute(
"Products",
"Products/{id}/{make}/{model}",
new { controller = "Products", action = "Index", id = UrlParameter.Optional, make = UrlParameter.Optional, model = UrlParameter.Optional });
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional });
The Select_Vehicle page should generate links like this:
/products/horns/dodge/dakota
but what I get is this:
/Products/Index/horns?make=dodge&model=Dakota
It just doesn't work properly. Also, I don't understand why "Index" also shows since it is the default.
I've tried both ActionLink and RouteLink:
@Html.RouteLink(model, new { Controller = "Products", id = Model.CategoryName, make = Model.CurrentMake, model = model })
@Html.ActionLink(model, "Index", "Products", new { id = Model.CategoryName, make = Model.CurrentMake, model = model }, null)
This is driving me crazy.