ASP.NET MVC: Get lowercase links (instead of Camel Case)

All my dynamically generated action links, etc. create links like / A ccount / S etup. It looks weird.

I want all my links to be lowercase (value / account / setting). Any way to do this?

+2
source share
3 answers

Take a look at http://goneale.com/2008/12/19/lowercase-route-urls-in-aspnet-mvc/ . You can find additional information in another stackoverflow thread in How can I have lowercase routes in ASP.NET MVC? .

The remaining posts have not yet reviewed the scenario in which you go to the root of your web directory. If you have a mapping that references the action of the HomeController index, you would like the following URL to appear:

mysite/home/ or even mysite/home/index

No amount of using the Html helper function will change the fact that by default the following will be displayed in the browser location bar:

mysite/Home or mysite/home/index

+3
source

There is a simpler solution in the .NET Framework 4.5, the new RouteCollection.LowercaseUrls property , here is an example

+6
source

Html:

public static class MyHtmlExtensions
{
    public static string LowerActionLink(this HtmlHelper htmlHelper,someargs)
    {
        return String.ToLowerInvariant(htmlHelper.ActionLink(someArgs));
    }
}

Html.LowerActionLink Html.ActionLink

0
source

Source: https://habr.com/ru/post/1752183/


All Articles