.net - URL Routing in MVC C# -


i defining application urls like

domainname.com/storecontroller/storeaction/storename 

i want rewrite like

domainname.com/storecontroller/storename 

actually, need skip storeaction url, don't want querystring "?" there anyway registering rout config path or way?

yes. can define action default parameter, , match specific controllers regex constraint:

routes.maproute("<route name>", "{controller}/{storename}",       new       {           action = "storeaction"       },      new      {          controller = "somecontroller1|somecontroller2|somecontroller3",      }); 

(action have default value "storeaction")

note need define route before default generic route doesn't catch before kicks in.


Comments