So I have added this route to my map:
routes.MapRoute(
"Default",
"/Bikes/{id}",
new { controller = "Bike", action = "Detail" }
);
But for SEO reasons we need to have urls like: /bikes/54/name-of-bike/kind-of-bike/number-of-wheels ... etc etc. But everything after id (54) can be ignored.
Does anyone know how to create suc开发者_StackOverflow社区h a MapRoute to allow that, the route above does not work actually for urls that contain stuff after the id.
You can use a catchall parameter like so
routes.MapRoute(
"Default",
"/Bikes/{id}/{*stuff}",
new { controller = "Bike", action = "Detail", stuff = UrlParameter.Optional }
);
then anything after id will be stored in stuff
Something like this
routes.MapRoute(
"Default",
"/Bikes/{id}/{slug*}",
new { controller = "Bike", action = "Detail",
slug = UrlParameter.Optional}
);
精彩评论