var identity = new ClaimsIdentity(); identity.AddClaim(new Claim("role", "admin"));
var identity = new ClaimsIdentity(); identity.AddClaim(new Claim("email_verified", "true"));
var identity = new ClaimsIdentity(); identity.AddClaim(new Claim("my_claim_type", "my_claim_value"));In each of these examples, a new claim is added to the identity using the AddClaim method. The first argument to the Claim constructor is the type of the claim, and the second argument is the value. Once the claim has been added to the identity, it can be used to control access to resources within the application. The System.Security.Claims library is part of the .NET framework and is included with all versions of .NET.
public AddClaim ( |
||
claim | the |
|
return | void |