Claim Value

    public static class IdentityExtension
    {
        public static string GetId(this IIdentity identity)
        {
            ClaimsIdentity claimsIdentity = identity as ClaimsIdentity;

            Claim claim = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier);

            return claim.Value;
        }
    }
Example:
User.Identity.GetId();

Description

C# with get claim value

Details

  • Author: Fatih Erol
  • Submitted on: 12/29/2017 10:32:01 PM
  • Language: C#
  • Type: Claim
  • Views: 828

Double click on the code to select all.

 

;