User.IsInRole() always returns false only in controller

Bartek Chyży

As in the title User.IsInRole() always returns false in controller but works well in view. Additionally I cannot set <roleManager enabled="true" />, because I am getting following error while project building

It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.

Any sugestions? Or is there any other way to check if current user is in role? (I tried Roles.IsUserInRole(User.Identity.Name, "Recruit") but i got same result). I am using ASP.NET MVC 5 and .NET Identity 6.2


Roles.IsUserInRole is part of MembershipProvider. If you are using Asp.Net Identity, you need to use RoleManager (MSDN) instead.

Reason because you can use User.IsInRole - Identity framework supports this call, it looks into a cookie, checks what roles are available in the cookie.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at


Login to comment


TOP Ranking