TryRemoveClaim() public méthode

It is possible that a Claim returned from Claims cannot be removed. This would be the case for 'External' claims that are provided by reference.

object.ReferenceEquals is used to 'match'.

public TryRemoveClaim ( Claim claim ) : bool
claim Claim the to match.
Résultat bool
 public static void ReplaceClaim(this ClaimsIdentity identity, string type, string value)
 {
     identity.TryRemoveClaim(identity.Claims.FirstOrDefault(c => c.Type == type));
     identity.AddClaim(new Claim(type, value));
 }