【发布时间】:2020-09-05 08:05:31
【问题描述】:
您好,我正在处理 JWT 令牌并尝试使用 Asp .net 核心使用剃刀视图声明角色。为此,我尝试使用以下代码。
@{
var jwtHandler = new JwtSecurityTokenHandler();
var tokenContent = jwtHandler.ReadToken(tokenModel.Result) as JwtSecurityToken;
var role = tokenContent.Claims.First(claim => claim.Type == "Role").Value;
var email = tokenContent.Claims.First(claim => claim.Type == "email").Value;
}
我收到此错误:
the type or namespace name 'jwtsecuritytokenhandler' could not be found
如何使用 razor 视图声明角色?
【问题讨论】:
-
检查这是否回答了您的问题:stackoverflow.com/questions/27139068/…
标签: asp.net-core razor jwt token roles