在ASP.NET MVC 5中,我在控制器中需要获取发起请求的用户:
ApplicationUser user = System.Web.HttpContext.Current.GetOwinContext().GetUserManager<ApplicationUserManager>().FindById(System.Web.HttpContext.Current.User.Identity.GetUserId());
使用ApplicationUser实例,如何获取用户的所有角色?