ASP0001 warning when used inside app.MapWhen
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
I try to create a webapp with a port dedicated to grpc and another port dedicated to openapi with dotnet6
```
var app = builder.Build();
app.MapWhen(context => context.Connection.LocalPort == myGrpcPort, grpcApp =>
{
grpcApp.UseRouting();
grpcApp.UseAuthentication();
grpcApp.UseAuthorization();
grpcApp.UseEndpoints(routeBuilder =>
{
routeBuilder.MapGrpcService();
routeBuilder.MapCodeFirstGrpcReflectionService();
});
});
app.MapWhen(context => context.Connection.LocalPort == myOpenApiPort, openapiApp =>
{
openapiApp.UseRouting();
openapiApp.UseAuthentication();
openapiApp.UseAuthorization(); //this triggers the warning
openapiApp.UseEndpoints(routeBuilder => routeBuilder.MapControllers());
```
When executing `dotnet run`
```
warning ASP0001: The call to UseAuthorization should appear between app.UseRouting() and app.UseEndpoints(..) for authorization to be correctly evaluated
```
If I comment the grpcApp part, the warning disappear
If I swap openapiApp before grpcApp, the warning is triggered in the grpc part
=> how can I avoid the warning in the second app.MapWhen ?
Contributor guide
Assessment
This issue has not been assessed yet.