【发布时间】:2014-08-26 15:31:14
【问题描述】:
我正在使用带有 MVC 和 razor 视图的 Identity 2.1.0。我的一个观点通过这个 GET 控制器操作获得了所有用户的列表:
public async Task<ActionResult> Users()
{
return View(await UserManager.Users.ToListAsync());
}
在视图中有一个 foreach 遍历每个用户并显示常用信息,如电子邮件地址、用户名等。我想知道是否还有一种方法可以遍历每个用户的角色,以便我可以像这样显示每个用户的角色成员身份:
Customer
Employee
我无法弄清楚这一点。我的部分问题是我在 razor 视图中没有任何 Intellisense,也无法在 Google 上找到任何有用的信息。
视图模型是@model IEnumerable<XXXX_My_App.Models.ApplicationUser>。 ApplicationUser 有一个 IdentityUser 基类。
【问题讨论】:
标签: c# asp.net-mvc asp.net-identity