Routing optional parameters with dashes in MVC
- by Géza
I've made an routing definition like this:
routes.MapRoute("ProductSearch", "Search-{MainGroup}-{SubGroup}-{ItemType}",
new {
controller = "Product",
action = "Search",
MainGroup = "", SubGroup = "", ItemWebType = ""});
It is not working if the parameters are empty.
Actually it resolves the url, so Url.Action method resolves the path "Search-12--" but the link is not working, so the GET of the page is not working
With slashes it is working the Url.Action method makes "Search/12"
"Search/{MainGroup}/{SubGroup}/{ItemType}"
is it somehow possible to correct it?