Olivier Muhring

Olivier Muhring

  • NA
  • 150
  • 8.6k

Acquiring all roles an authenticated user has in

Sep 7 2020 10:51 AM
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.
  1. @using Microsoft.AspNetCore.Identity  
  2.   
  3. <header>  
  4. @{  
  5. if (User.Identity.IsAuthenticated)  
  6. {  
  7. UserManager<IdentityUser> userManager = new UserManager<User>();  
  8.   
  9. var rolesArray = userManager.GetRolesAsync(User.Identity.??);  
  10. }  
  11. }  
  12. </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