2

I'm getting this error:

Line 246:       <roleManager>
Line 247:           <providers>
Line 248:               <add name="AspNetSqlRoleProvider"     connectionStringName="LocalSqlServer" applicationName="/"  type="System.Web.Security.SqlRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral,     PublicKeyToken=b03f5f7f11d50a3a"/>
Line 249:               <add name="AspNetWindowsTokenRoleProvider" applicationName="/" type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
Line 250:           </providers>

Source File: C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config    Line: 248 

However, it shouldn't be as we're not using the aspnetroleprovider. But it's in the machine.config. Other sites don't have this problem. What could be making it pick up the aspnetsqlroleprovider?

Paul
  • 9,409
  • 13
  • 64
  • 113

2 Answers2

6

fix

add enableSimpleMembership with value false app setting to your web.config.

cause

<roleManager enabled="false" />

will cause Roles.Enabled flag to be set to false, as expected,

but there is 'WebMatrix.WebData.WebSecurity' that says:

internal static void PreAppStartInit()
{
  if (!ConfigUtil.SimpleMembershipEnabled)
    return;
  ...
  Roles.Enabled = true;
  const string BuiltInRolesProviderName = "AspNetSqlRoleProvider";
  var builtInRoles = Roles.Providers[BuiltInRolesProviderName];
  if (builtInRoles != null)
  {
      var simpleRoles = CreateDefaultSimpleRoleProvider(BuiltInRolesProviderName, currentDefault: builtInRoles);
      Roles.Providers.Remove(BuiltInRolesProviderName);
      Roles.Providers.Add(simpleRoles);
  }
  ...
}

this will override roleManager setting (this code is executed before RoleManager module is), including adding AspNetSqlRoleProvider

to disable 'SimpleMembership' you can add app setting enableSimpleMembership with value="false" (web.config):

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
    <appSettings>
        <add key="enableSimpleMembership" value="false" />
    </appSettings>
</configuration>

this will prevent webmatrix from reconfiguring RoleManager.

THX-1138
  • 21,316
  • 26
  • 96
  • 160
1

Add the <clear/> to your web.config's section of role providers. On this way you avoid inheriting if you don't use one. You should add it also for Membership and Profile providers section.

<roleManager>
   <providers>
      <clear/>
   </providers>
   ....

Edit: Maybe you need to remove it explicitely:

<roleManager>
       <providers>
          <clear/>
          <remove name="AspNetSqlRoleProvider" />

Another try:

Disable the role provider:

<system.web>
    <roleManager enabled="false" />
</system.web>

http://msdn.microsoft.com/en-us/library/ms998314.aspx#paght000013_step2

Tim Schmelter
  • 450,073
  • 74
  • 686
  • 939