EndpointRoutingMiddleware matches endpoints setup by EndpointMiddleware
System.InvalidOperationException:“EndpointRoutingMiddleware matches endpoints setup by EndpointMiddleware and so must be added to the request execution pipeline before EndpointMiddleware. Please add EndpointRoutingMiddleware by calling 'IApplicationBuilder.UseRouting' inside the call to 'Configure(...)' in the application startup code.”
执行以下代码报错:
C# 全选
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers().RequireAuthorization();
});
解决方案
在执行上述代码前先调用UseRouting方法:
C# 全选
app.UseRouting();
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网