Controller routing and actions in lowercase

3

How to make the controllers and actions routes all in lowercase?

For example: instead of Noticias/Details get noticias/details .

    
asked by anonymous 31.07.2015 / 14:38

1 answer

6

You can use a library ( Nuget ) to do this. Here are the instructions on how to install and use it.

But if you are using .Net 4.5 or higher, you can configure it without libraries:

public static void RegisterRoutes(RouteCollection routes) {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
        routes.LowercaseUrls = true;
        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );
    }

Retired from answer in SO . In the same question you have other ways to do this.

    
31.07.2015 / 14:48