I suspect you have registered ASP.NET Core Identity with both your MVC (Views) Part as well as with your WebApi part.
You must separate it and the CookieMiddleware (one registered inside .UseIdentity()
call) must only be registered for request to your MVC pages, but not for your WebAPI calls.
You can use the .Map
or MapWhen
methods (see docs).
// For requests not going to WebAPI controllers
app.MapWhen(context => !context.Request.Path.StartsWithSegments("/api"), branch =>
{
branch.UseIdentity();
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…