In ASP.NET MVC 5, in a controller, I have take the user that has make the request with:
ApplicationUser user = System.Web.HttpContext.Current.GetOwinContext().GetUserManager<ApplicationUserManager>().FindById(System.Web.HttpContext.Current.User.Identity.GetUserId());
With the ApplicationUser instance, how can i get all the Roles of the user?
You can get user and assigned roles by using UserManager.
var userManager = HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>();
and then you can get your user like you already did, and also you can get roles for particular user by calling GetRoles method
userManager.GetRoles(userId);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With