Can't get claims from JWT token with ASP.NET Core

前端 未结 4 1074
南笙
南笙 2021-02-12 22:49

I\'m trying to do a really simple implementation of JWT bearer authentication with ASP.NET Core. I return a response from a controller a bit like this:

    var i         


        
4条回答
  •  深忆病人
    2021-02-12 23:12

    You can't use ClaimsPricipal.Current in an ASP.NET Core application, as it's not set by the runtime. You can read https://github.com/aspnet/Security/issues/322 for more information.

    Instead, consider using the User property, exposed by ControllerBase.

提交回复
热议问题