Why builder.Use is not working after migrating from net5 to net6?

Viewed 16

After I've changed version of the .NET from 5 to 6, error in WebStartup.cs started to appear.

Code looks like this:

app.Map("/status", builder =>
{
        builder.Use(async (context, next) =>
        {
           Log.Debug(context.GetRequestLogString());
           context.Response.StatusCode = StatusCodes.Status200OK;
           await context.Response.WriteAsync("OK");
        });
});

And the Use word is underlined.

And here is the error message I can see for this part of code:

The call is ambiguous between the following methods or properties: 
'UseExtensions.Use(IApplicationBuilder, Func<HttpContext, Func<Task>, Task>)' and 
'UseExtensions.Use(IApplicationBuilder, Func<HttpContext, RequestDelegate, Task>)'  

What should I change to make this work in net6?

0 Answers
Related