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

前端 未结 7 1229
陌清茗
陌清茗 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:05

    If you are using ASP.NET Core 3.0

    Check this order

    app.UseAuthentication();

    app.UseRouting(); //must be below app.UseAuthentication();

    If you are using ASP.NET Core < 3.0

    Just replace the app.UseRouting(); by app.UseMvc();

    i.e:

    app.UseAuthentication();

    app.UseMvc(); //must be below app.UseAuthentication();

提交回复
热议问题