flu*_*ter 5 c# jwt asp.net-identity asp.net-core
我JwtSecurityTokenHandler用来在ASPNET核心Web API应用程序中发行令牌:
JwtSecurityToken token = BuildJwtSecurityToken(...);
public string toks = new JwtSecurityTokenHandler().WriteToken(token);
Run Code Online (Sandbox Code Playgroud)
每次请求和创建令牌时,都会实例化一个新的JwtSecurityTokenHandler,我可以使用它的全局实例并将其用于每一代令牌吗?
private JwtSecurityTokenHandler handler = new JwtSecurityTokenHandler();
private GenToken(JwtSecurityToken token) => handler.WriteToken(token);
Run Code Online (Sandbox Code Playgroud)
这样使用有什么问题吗?
文档说不保证实例成员JwtSecurityTokenHandler是线程安全的。
| 归档时间: |
|
| 查看次数: |
527 次 |
| 最近记录: |