Get list of users with assigned roles in asp.net identity 2.0

后端 未结 8 2017
你的背包
你的背包 2020-12-23 21:13

I have a drop down list box which lists roles. I want to get the list of users having that role. I mean list of users that are in \"Administrator\" role or \"CanEdit\" role.

8条回答
  •  误落风尘
    2020-12-23 21:19

    the code working for me was as following:

      var users = roleManager.FindByName(roleName).Users.Select(x => x.UserId);
      var usersInRole = Users.Where(u => users.Contains(u.Id));
    

提交回复
热议问题