Search code examples
c#asp.net-mvc-4simplemembership

Use Roles.GetUsersInRole for more then one role


Am using MVC4 SimpleMemebership in my application ..Am retrieving a list of all user in certain role using this :

     public ActionResult Index()
    {

        var s = Roles.GetUsersInRole("Admin");
        var m = Roles.GetUsersInRole("Member");

        return View(s);

you can see am passing the s list so am Only getting the user who have " Admin"Role. I want to have list of all user in (Admine and Memeber) in my list how to do that ?


Solution

  • You have to combine both results, first. Of course one user can be in multiple rules so you might get duplicate results which you have to eliminate then. You can do this using Linq:

    return View(s.Union(m).Distinct());