Answers for "jwtsecuritytoken to c# object"

C#
0

C# .net JwtSecurityTokenHandler jwttoken claims to object

You should be able to retrieve a claims like this within your controller

var identity = HttpContext.User.Identity as ClaimsIdentity;
if (identity != null)
{
    IEnumerable<Claim> claims = identity.Claims; 
    // or
    identity.FindFirst("ClaimName").Value;

}
If you wanted, you could write extension methods for the IPrincipal interface and retrieve claims using the code above, then retrieve them using (for example)

HttpContext.User.Identity.MethodName();
Posted by: Guest on October-26-2021
0

C# .net JwtSecurityTokenHandler jwttoken claims to object

var identity = HttpContext.User.Identity as ClaimsIdentity;
if (identity != null)
{
    IEnumerable<Claim> claims = identity.Claims; 
    // or
    identity.FindFirst("ClaimName").Value;

}
Posted by: Guest on October-26-2021

C# Answers by Framework

Browse Popular Code Answers by Language