How to retrieve Claims Value in .Net Core

How to retrieve Claims Value in .Net Core

 

Use the "System.Security.Claims" namespace to retrieve/get user claims in ASP.NET

 

var u_claims = ClaimsPrincipal.Current.Identities.First().Claims.ToList();    
    
//Filter claim    
u_claims ?.FirstOrDefault(x => x.Type.Equals("UserName", StringComparison.OrdinalIgnoreCase))?.Value;

2021-10-03