METHOD
ClaimsPrincipal.IsInRole
Checks for a role claim across the principal’s identities using each identity’s RoleClaimType. It does not independently authenticate the principal or establish resource ownership.
Formal Syntax & Structure
csharp syntaxcsharp
principal.IsInRole("Reader")Working Example
Example Snippetcsharp
using System;using System.Security.Claims;using System.Linq;var identity = new ClaimsIdentity(new[]{new Claim("group","Reader")},"Synthetic","name","group");Console.WriteLine(new ClaimsPrincipal(identity).IsInRole("Reader")); // True