I am trying to implement basic role management manually. When a user logs in if they are admin or not they are added to a role
I am getting this error:Except
I tried this in MVC 5 and it worked:
<system.web>
<authentication mode="None" />
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<roleManager enabled="true" />
</system.web>
After adding the "roleManager" line shown above to the web.config, I could add a new role and add a user to the role without any exception:
if (!Roles.RoleExists(_role))
Roles.CreateRole(_role);
if (!Roles.IsUserInRole(_username, _role))
Roles.AddUserToRole(_username, _role);
With your DefaultRoleProvider try this
<roleManager defaultProvider="DefaultRoleProvider" enabled ="true">
By default the role manger is disabled, so you have to enable it explicitly:
<roleManager enabled="true" defaultProvider="DefaultRoleProvider">