UsePathBase should insert before UseRouting() in WebApplicationBuilder.ConfigureApplication #59638
Open
1 task done
Labels
area-minimal
Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc
Is there an existing issue for this?
Is your feature request related to a problem? Please describe the problem.
I am trying use PathBaseMiddleware with WebApplicationBuilder and auth such as:
when I access https://localhost:8080/example/api/weatherforecast, a exception page show:
This is becasue when I add UsePathBase(...), it will add a UseRoute after UsePathBase without Authorization.
WebApplication generate a middleware like this:
5.1 UsePathBase(...);
5.2 UseRouting(...)
5.3 other middleware user added.
The final UseEndpoints(...) middleware will execute authz. The endpoint is matched on step 5.2。step 3 will not execute because no endpoint matched on step 2.
Describe the solution you'd like
Add UsePathBase(...) to WebApplicationBuilder.ConfigureApplication(...) when environment ASPNET_PATHBASE set.
Additional context
No response
The text was updated successfully, but these errors were encountered: