ExtensionMethod.NET Home of 880 C#, Visual Basic, F# and Javascript extension methods

Claim Value

C# with get claim value

Source

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();

Author: Fatih Erol

Submitted on: 29 dec. 2017

Language: C#

Type: Claim

Views: 4640