About this Project
Tired of your MVC application generating mixed-case URLs likeHttp://mysite.com/Home/AboutOrhttp://mysite.com/Admin/Customers/List? Wouldn ' tHttp://mysite.com/home/aboutandhttp://mysite.com/admin/customers/listis a lot nicer? I think so too, so I wrote the little project to help make that work.
By default, ASP. NET MVC generates outgoing route URLs that preserve the casing of your controller and action names. Since controllers isClassesand actions areMethods, these outgoing URL segments would most likely be camel-cased, as that's the standard when naming these constructs.LowercaseroutesmvcLets very easily make ASP. Generate outgoing route URLs that is always lower-cased, without have to rename a NY of your controller classes or action methods. It includes support for MVC areas as well. (If the generated outgoing URL contains a querystring, its casing won't be affected.)
There is also a separate beta versionWith lower-casing HTTP Routes generated by the ASP.
Usage Notes
Using This project is very easy. Once added as a reference in your Web project, you need only do a minor change to the method calls in your Registerr Outes method in Global.asax. If you is using areas in your project, you'll also make similar changes in the Registerarea override (s) in your is A registration classes
Step 1. -Install the library via Nuget
Pm> Install-package Lowercaseroutesmvc or via the NuGet management tools in Visual Studio.
If you need the support for lower-casing HTTP Routes, install the This version instead:
Pm> Install-package LowercaseRoutesMVC4
Step 2. -Remap Your Main Routes
Go to the RegisterRoutes method in Global.asax. Replace all the calls to MapRoute withmaproutelowercase.
For example:
Using LOWERCASEROUTESMVC. public static void RegisterRoutes (RouteCollection routes) { routes. Ignoreroute ("{resource}.axd/{*pathinfo}"); Routes. Maproutelowercase (//changed from routes. MapRoute "Default", "{controller}/{action}/{id}", new {controller = "Home", action = "Index", id = Urlparameter.optional} );}
Step 3. (If using areas)-Remap Your area Routes
Go to the Registerarea override in the area registration class for each of the your application. (For example, if you have a area named Admin, this class would be called Adminarearegistration and would be located In theareas/admin folder.) Again, Replace all the calls to MapRoute with maproutelowercase.
For example:
Using LOWERCASEROUTESMVC. public override void Registerarea (AreaRegistrationContext context) { context. Maproutelowercase (//changed from context. MapRoute "Admin_default", "Admin/{controller}/{action}/{id}", new {controller = "Home", action = "Index" , id = urlparameter.optional} );}
Step 4. (If using ASP. NET Web API)-Remap Your HTTP Routes
There is a separate Nuget package called LowercaseRoutesMVC4 that contains all of the functionality above, plus B ETA support for lower-casing HTTP Routes generated by the ASP. If This is something your ' re interested in doing, being sure to install the LowercaseRoutesMVC4 Nuget package and not the Lowe Rcaseroutesmvc one. the Keep in mind, the ASP. NET Web API is still in beta, and that the routing features was likely to change.
Go to the RegisterRoutes method in Global.asax. Replace all the calls to Maphttproute withmaphttproutelowercase.
For example:
Using LowercaseRoutesMVC4. public static void RegisterRoutes (RouteCollection routes) { routes. Ignoreroute ("{resource}.axd/{*pathinfo}"); Routes. Maphttproutelowercase (//changed from routes. Maphttproute "Defaultapi", "Api/{controller}/{id}", new {id = urlparameter.optional} );}
LOWERCASEROUTESMVC ASP. NET MVC routes to lowercase URLs