@Mohammed Waseem ,
Here is a Blazor example from the official documentation for retrieving the name of the user's first role:
<AuthorizeView>
<Authorized>
<p>@context.User.Claims.FirstOrDefault(c=>c.Type == "role").Value</p>
</Authorized>
</AuthorizeView>
The best way to retrieve the role is to get it from the roles claim in the JWT token (http://schemas.microsoft.com/ws/2008/06/identity/claims/role ).
In your authorization code, it is recommended to check whether a particular claim value is present, rather than assuming the user has just one role claim.
if (context.User.HasClaim(ClaimTypes.Role, "Admin")) { ... }
See related threads:
https://stackoverflow.com/questions/60402678/how-to-set-find-user-roles-from-organization-based-identity-in-net-core
https://stackoverflow.com/questions/60007447/blazor-authentication-with-azure-ad-retrieving-user-roles
Let me know if this is close to what you are looking for. We don't have an exact sample for this.
If the information helped you, please Accept the answer. This will help us as well as others in the community who may be researching similar questions. Otherwise let us know if you have further questions.