I'm trying to load an authenticated user's roles, since I need the data in every page I thought it best to add the code in _Layout.cshtml.
- @using Microsoft.AspNetCore.Identity
-
- <header>
- @{
- if (User.Identity.IsAuthenticated)
- {
- UserManager<IdentityUser> userManager = new UserManager<User>();
-
- var rolesArray = userManager.GetRolesAsync(User.Identity.??);
- }
- }
- </header>
But I can't seem to find out how exactly I can do that in the given context.
Can anyone here help?
PS: This might not be the best solution, but since I'm rather new @ this I would like to continue in this direction for the time being