Roles.GetUsersInRolereturns the string[]usernames in the role. If you really want objects MembershipUser, you can use:
var list = Roles.GetUsersInRole("roleName").Select(Membership.GetUser).ToList()
Of course, this is the intensity of the work, because it gets into the database once for each user.
If you are willing to give up provider independence, you can directly query the base database and connect to the database server to get all users in a specific role.
source
share