Controller and action routes in lower case

Asked

Viewed 81 times

4

How to make the routes of controllers and actions are all in lower case?

For example: instead of Noticias/Details stick around noticias/details.

1 answer

6


It is possible to use a library (Nuget) to do this. There are indications how to install and use it. It is possible that the project has been abandoned. Alternative.

But if you are using . NET 4.5 or higher you can configure 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 }
    );
}

I put in the Github for future reference.

Taken from response in the OS. In the same question there are other ways to do this.

  • This library is great. Thanks bro!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.