18

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 ?

1 Answer 1

47

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Interesting, you can call services.Configure<RouteOptions> options => { options.LowercaseUrls = true; });
Doesn't seem to apply to the login redirect url, but that was the case in RC1 as well.
I came across this setting while researching for the requirement to make all urls lowercase. I just can't see a difference (.NET core 1.1 web api, swagger behind IIS). It still accepts case insenstivie URLs. Any hints what should change and how I can test it?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.