PrincipalExtensions Class

Claims related extensions for System.Security.Claims.ClaimsPrincipal.

Namespace
System.Security.Claims
Assemblies
  • Microsoft.AspNetCore.Identity

Syntax

public class PrincipalExtensions
class System.Security.Claims.PrincipalExtensions

Methods

FindFirstValue(System.Security.Claims.ClaimsPrincipal, System.String)

Returns the value for the first claim of the specified type otherwise null the claim is not present.

Arguments:
  • principal (System.Security.Claims.ClaimsPrincipal) – The System.Security.Claims.ClaimsPrincipal instance this method extends.
  • claimType (System.String) – The claim type whose first value should be returned.
Return type:

System.String

Returns:

The value of the first instance of the specified claim type, or null if the claim is not present.

public static string FindFirstValue(this ClaimsPrincipal principal, string claimType)