Home>

As the title suggests, we would like to display a list of users belonging to a specific role in the ASP.NET MVC&Identity environment.

var model = UserManager.Users.Where (???). ToList ();
I think I can use the IsInRole method.

Thank you.


Windows10 Pro
VS2017 C #
SQLServer 2017 Express

  • Answer # 1

    var allusers = UserManager.Users.ToList ();
    var model = allusers.Where (u =>UserManager.IsInRole (u.Id, "GoldMember")). ToList ();
    return View (model);

    It worked fine with

    .

  • Answer # 2

    Understand that it is not CORE ...

    If you like the following,

    (1) View the Role list

    (2) Display the role assignment status for each user

    You can do it like the following article.

    ASP.NET Identity Role Management (MVC)
    http://surferonwww.info/BlogEngine/post/2017/11/02/role-management-on-aspnet-identity-for-mvc-application.aspx