How do you enforce lowercase routing in ASP.NET Core?

前端 未结 6 1873
Happy的楠姐
Happy的楠姐 2020-12-04 12:11

In ASP.NET 4 this was as easy as routes.LowercaseUrls = true; in the RegisterRoutes handler for the app.

I cannot find an equivalent in ASP

6条回答
  •  醉梦人生
    2020-12-04 12:23

    Found the solution.

    In the assembly: Microsoft.AspNet.Routing, and the Microsoft.Extensions.DependencyInjection namespace, you can do this in your ConfigureServices(IServiceCollection services) method:

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

提交回复
热议问题