NickG
NickG

Reputation: 9812

How do you use use RouteOptions in .NET Core 5 MVC? (to force lowercase URLs etc)

I want to use lowercase URLs in my app and I can see there's a RouteOptions object documented here:

https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.routing.routeoptions?view=aspnetcore-5.0

But how do you actually use RouteOptions?

I thought it would be something similar to the below, but it just generates a compiler warning saying that app.UseRouting() doesn't take any parameters:

app.UseRouting(options => {
    options.<no intellisense>
});

So can someone please let me know where I can specify RouteOptions?

Upvotes: 3

Views: 1651

Answers (1)

DavidG
DavidG

Reputation: 118957

You need to configure this in your ConfigureServices method, for example:

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

Upvotes: 5

Related Questions