Hi. I have a problem with rouing in asp.net mvc.
How can i redirect :
route - controller/action
{brand}-car-prices -> /PriceList/PricesByBrand (For example : "toyota-car-prices")
{color}-{brand}-car-prices -> /PriceList/PricesByColorAndBrand {for example : "green-toyota-car-prices"}
{modelyear}-car-prices -> /PriceList/PricesByModelYear {for example "2005-car-prices"}
{modelyear}-{brand}-car-prices -> /PriceList/PricesByModelYearAndBrand {for example "2005-toyota-car-prices"}
when i routing, all routes redirecting same action (page).
How can i do correct?
What I have tried:
routes.MapRoute(
name: "carprices",
url: "{brand}-car-prices/{page}",
defaults: new { controller = "PriceList", action = "PricesByBrand ", brand= UrlParameter.Optional, page = UrlParameter.Optional },
namespaces: new[] { "MyProject.Controllers" }
);
routes.MapRoute(
name: "colorcarprices",
url: "{color}-{brand}-car-prices/{page}",
defaults: new { controller = "PriceList", action = "PricesByColorAndBrand ", color= UrlParameter.Optional, brand= UrlParameter.Optional, page = UrlParameter.Optional },
namespaces: new[] { "MyProject.Controllers" }
);