urlreader
urlreader

Reputation: 6615

SimpleMembership: how to get a list of users in a Role?

I'm using SimpleMembership in MVC4 with Entity Framework. When create edmx, for some reasons, the table webpages_UsersInRoles does not generate class (probably it is because this table is only an association).

Now, how can I get a list users that are in a Role, i.e. All admins?

Or, I have to get all users, then check whether each is in the Admin role?

Thanks

Upvotes: 0

Views: 479

Answers (1)

NightOwl888
NightOwl888

Reputation: 56909

Use the built-in Roles.GetUsersInRole method.

var usersInRole = Roles.GetUsersInRole("Admin");

References:

Upvotes: 1

Related Questions