The Role Manager feature has not been enabled ?

Published on Friday, April 1, 2011

When you run ASP.NET web application, and when you try to do a Role operation such as adding a role, you might get an error message:

The Role Manager feature has not been enabled.

This error message is not from your code, it is from ASP.NET. The reason is that By default the Roles provider in machine.config and also in default web.config file it is set to disable:

<roleManager enabled=�false�>
      <providers>
        <clear/>
        <add name=�AspNetSqlRoleProvider� type=�System.Web.Security.SqlRoleProvider� connectionStringName=�ApplicationServices� applicationName=�/� />
        <add name=�AspNetWindowsTokenRoleProvider� type=�System.Web.Security.WindowsTokenRoleProvider� applicationName=�/� />
      </providers>
    </roleManager>

So just change the setting enabled=“true” then this issue can be resolved.

If you are going to your own role provider, then you should remove the default “AspNetSqlRoleProvider” from web.config (above sameple), and then add your own, for example:

        <roleManager defaultProvider=�TRoleProvider� enabled=�true�>
            <providers>
                <clear/>
                <!�<add name=�AspNetSqlRoleProvider� type=�System.Web.Security.SqlRoleProvider� connectionStringName=�ApplicationServices� applicationName=�/� />
        <add name=�AspNetWindowsTokenRoleProvider� type=�System.Web.Security.WindowsTokenRoleProvider� applicationName=�/� />�>
                <add name=�MyRoleProvider� type=�xxxProject.myRoleProvider� connectionStringName=�xxxx� applicationName=�xxxxx� writeExceptionsToEventLog=�false�/>
            </providers>
        </roleManager>