📜  如何在服务中解码 Microsoft 本地令牌 - C# 代码示例

📅  最后修改于: 2022-03-11 14:49:16.595000             🧑  作者: Mango

代码示例1
// Getting Decoded Token from the HTTP context
// May very according to place where you are using it.
// You can use it in Controller/AttributeFilter/Middlerware.

var identity = HttpContext.User.Identity as ClaimsIdentity;

// Gets list of claims.
IEnumerable claims = identity.Claims;

// Can find any value from claim by changing below code
var Name = claims.Where(x => x.Type == ClaimTypes.Name).ToArray();

// Do the next opertaion