You can get all the roles assigned to a user, and check if there’s any. There’s no need for a
for loop, you just want to know that it’s not empty.
var roles = await _userManager.GetRolesAsync(user); var hasAnyRole = roles.Count > 0;
CLICK HERE to find out more related problems solutions.