Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lowercase urls in .NET Core RC2

In .net 5 / MVC 6 RC1 we could force lowercase urls in routes with the following:

services.ConfigureRouting(options =>
{
    options.LowercaseUrls = true;
});

How is this accomplished in RC2 / .net core 1.0 ?

like image 874
ScottE Avatar asked May 24 '16 20:05

ScottE


People also ask

How do you enforce lowercase routing in asp net core?

To ensure that query strings are also lowercase, set the options. LowercaseQueryStrings to true : services. Configure<RouteOptions>(options => { options.


1 Answers

I think that you're now looking for the .AddRouting extension method instead. You "configure" the instance of the RouteOptions as part of the addition of the service:

services.AddRouting(options => options.LowercaseUrls = true);

Update

You can also call the following:

services.Configure<RouteOptions>(options => options.LowercaseUrls = true);

I detailed some of the API changes in my blog post here.

like image 114
David Pine Avatar answered Oct 27 '22 09:10

David Pine