Попробуйте это
@inject SignInManager<AspNetMvcCore.Services.Models.User> SignInManager
@if (SignInManager.IsSignedIn(User) && User.IsInRole("Admin"))
{
}
@if (SignInManager.IsSignedIn(User) && User.IsInRole("User"))
{
}
и добавьте роли
public class HomeController : Controller
{
private readonly RoleManager<IdentityRole> _roleManager;
public HomeController(RoleManager<IdentityRole> roleManager)
{
_roleManager = roleManager;
}
[HttpGet]
public async Task<IActionResult> Index()
{
IdentityResult createUserRole = await _roleManager.CreateAsync(new IdentityRole("User"));
IdentityResult createAdminRole = await _roleManager.CreateAsync(new IdentityRole("Admin"));
}
}