Прочитај на енглеском Уреди

Делите путем


ClaimsPrincipal.HasClaim Method

Definition

Determines whether any of the claims identities associated with this claims principal contains a claim that matches specified conditions.

Overloads

HasClaim(Predicate<Claim>)

Determines whether any of the claims identities associated with this claims principal contains a claim that is matched by the specified predicate.

HasClaim(String, String)

Determines whether any of the claims identities associated with this claims principal contains a claim with the specified claim type and value.

HasClaim(Predicate<Claim>)

Source:
ClaimsPrincipal.cs
Source:
ClaimsPrincipal.cs
Source:
ClaimsPrincipal.cs

Determines whether any of the claims identities associated with this claims principal contains a claim that is matched by the specified predicate.

C#
public virtual bool HasClaim(Predicate<System.Security.Claims.Claim> match);

Parameters

match
Predicate<Claim>

The function that performs the matching logic.

Returns

true if a matching claim exists; otherwise, false.

Exceptions

match is null.

Remarks

Each ClaimsIdentity is called.

See also

ClaimsIdentity.HasClaim(String, String).

Applies to

.NET 10 и друге верзије
Производ Верзије
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0

HasClaim(String, String)

Source:
ClaimsPrincipal.cs
Source:
ClaimsPrincipal.cs
Source:
ClaimsPrincipal.cs

Determines whether any of the claims identities associated with this claims principal contains a claim with the specified claim type and value.

C#
public virtual bool HasClaim(string type, string value);

Parameters

type
String

The type of the claim to match.

value
String

The value of the claim to match.

Returns

true if a matching claim exists; otherwise, false.

Exceptions

type or value is null.

Remarks

Does not check the Issuer or OriginalIssuer properties. The comparison is made using Ordinal, case sensitive on value; case in-sensitive on type.

Applies to

.NET 10 и друге верзије
Производ Верзије
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0