in my project, I have a user with 2 position, so, I have added a user with 2 roles in AspNetUserRoles table in my database,
so, for example, my user with this username : "[email protected]" has 2 roles: "accountant" and "ExecutiveExpert"
but when I call User.IsInRole("ExecutiveExpert") function, it just check the first role : accountant, not all the roles (accountant and ExecutiveExpert) and it returns false,
how can I change the asp.net Identity to check all the user roles? is it possible generally ?
these are my tables :
[AspNetUsers]:ID: c35721e2-05ef-4c32-8915-b4ad117c5a98 [AspNetRoles]: Id Name 743f5c09-2b94-4da6-ab1c-9c9a6c9373b7 accountant 845efdf6-ab07-475c-9eb1-b14365b1a54c ExecutiveExpert [AspNetUserRoles]: userID RoleID c35721e2-05ef-4c32-8915-b4ad117c5a98 743f5c09-2b94-4da6-ab1c-9c9a6c9373b7 c35721e2-05ef-4c32-8915-b4ad117c5a98 845efdf6-ab07-475c-9eb1-b14365b1a54c
User.IsInRolewill just give you a boolean. If it has the specified role, you'll get true, otherwise false.stringtoIsInRole. See the docsbool hasBothRoles = User.IsInRole("Role1") && User.IsInRole ("Role2");IfIsInroleis reporting the wrong thing for a single role, then you've got a completely different issue.