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

后端 未结 8 2000
你的背包
你的背包 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:32

    If you want to avoid using the context directly you can use the RoleManager with the following snippet

    roleManager.FindByName("Administrator").Users
    

    or

    roleManager.FindByName("CanEdit").Users
    

    For a short discussion about this topic have a look at the this thread

提交回复
热议问题