1

I am using the default ASP identity modelin my MVC application.

as per this post, I want to get a list of users which are in a role:

var users = Roles.GetUsersInRole("employee");

However, this always throws

The role 'employee' was not found.

Even though that role definitely does exist.

I can confirm this, as I am able to call :

User.IsInRole("employee")

For the current user, and this returns true.

I also noticed that these methods always return empty arrays:

var r = Roles.GetAllRoles();
var au = Membership.GetAllUsers();

Why is this?

I know I can get the roles by directly making calls to the database context, but why can't I use the built in methods?

Bassie
  • 9,529
  • 8
  • 68
  • 159
  • 1
    If you're using Identity framework, then you shouldn't be using the `Roles` and `Membership` objects. – DavidG Oct 05 '17 at 10:41

0 Answers0