Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 803
NickG Avatar asked Nov 21 '25 19:11

NickG


1 Answers

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

services.Configure<RouteOptions>(options =>
{
    options.LowercaseUrls = true;
});
like image 88
DavidG Avatar answered Nov 24 '25 23:11

DavidG



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!