Lowercase route URLs automatically in Razor Pages 2.0

In Razor Pages 2.0, the routing system is based on file locations within the project's root directory.


If the project has mixed case page names, then ASP.NET will generate URLs are also mixed case.


I was about to add this to the very shortlist of things I do not like about Razor Pages; however, there is a configuration setting to enable lowercase URLs.

In Startup.cs, find the ConfigureSettings method, and make the following change:

public void ConfigureServices(IServiceCollection services)
    services.AddRouting(options => options.LowercaseUrls = true);

That is it!



Show Comments