Is it possible to use comma instead of slash in routing path. Example
localhost/products,news
instead of
localhost/products/news
Thank you!
Is it possible to use comma instead of slash in routing path. Example
localhost/products,news
instead of
localhost/products/news
Thank you!
You can map a route like this:
routes.MapRoute(
"CommaSeperated",
"{controller},{action},{id}",
new { controller = "Home", action = "Index",
id = UrlParameter.Optional }
);
Update:
I found the problem. Commas are not treated like slashes. You can skip parameters when you are using slashes but that's not the case with commas. When you use commas you have to give all that's in the route. So you should provide all 3 parameters or it will not work. http://domain.com/files,details,3 will work but http://domain.com/files,index won't. There isn't a second comma in that URL so it won't match the route. So you write another route before the first one.
routes.MapRoute(
"CommaSeperated1",
"{controller},{action}",
new { controller = "Home", action = "Index" }
);