Search code examples
asp.net-mvclowercase

How to make ASP.NET MVC create lowercase urls (action links)?


I know this question has been asked many times. But people suggest creating custom derived route classes, or writing lowercase everywhere in code (for action links) which is a really dirty way (what if I just decide to make'em all Pascal Cased again? changing hundreds of links?), or they suggest to create HTML helpers to do that (which is not a bad answer). But isn't there a more simple way? I mean something like setting some configuration in web.config file, or using an HttpModule or something else which is both simple, and centralized?


Solution

  • Apart from the options you have already listed, I can think of no other way of producing this result.

    In short, the URL needs to be processed by 'something', be it .ToLower(), a Helper Method or HTTPModule.

    In most of our applications, we use a Global Static method that performs actions on the desired URI and returns the result.