ASP.NET MVC - Removing controller name from URL -


i want remove controller name url (for 1 specific controller). example:

http://mydomain.com/mycontroller/myaction

i want url changed to:

http://mydomain.com/myaction

how go doing in mvc? using mvc2 if helps me in anyway.

you should map new route in global.asax (add before default one), example:

routes.maproute("specificroute", "{action}/{id}", new {controller = "mycontroller", action = "index", id = urlparameter.optional});  // default route routes.maproute("default", "{controller}/{action}/{id}", new {controller = "home", action = "index", id = urlparameter.optional} ); 

Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -