Authorization in ASP.NET Core. Always 401 Unauthorized for [Authorize] attribute

前端 未结 7 1210
陌清茗
陌清茗 2021-01-07 18:22

For the first time I\'m creating Authorization in ASP.NET Core. I used tutorial from here TUTORIAL

The problem is when I sending request from postman:



        
7条回答
  •  花落未央
    2021-01-07 19:09

    in ASP.NET Core 3.0, i had the same problem, what worked for me was:

    app.UseRouting();
    app.UseAuthentication();
    app.UseAuthorization();
    

    in StartUp.Configure method.

    This doc shows typical ordering of middleware components: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/middleware/?view=aspnetcore-3.0

提交回复
热议问题