Default Role Provider could not be found on IIS 7 running .NET 4

Eric picture Eric · May 31, 2013 · Viewed 7.2k times · Source

Good morning all,

I am attempting to implement my custom membership and role providers in my web application that I have implemented under the Default Web Site in my instance of IIS 7. My web application is running under a .NET 4 application pool.

However, after setting up the corresponding web.config, I get the following error:

Parser Error Message: Default Role Provider could not be found.

I have included the following block of code in the system.web section of the corresponding web application's web.config:

<membership defaultProvider="CustomMembershipProvider" userIsOnlineTimeWindow="20">
 <providers>
  <clear/>
  <add name="CustomMembershipProvider" type="CustomProviders.CustomMembershipProvider,   
     CustomProviders, Version=3.0.0.0, Culture=neutral, 
     PublicKeyToken=3563615169617648" applicationName="/"/>
 </providers>
</membership>

<roleManager enabled="true" defaultProvider="CustomRoleProvider">
  <providers>
   <clear/>
   <add name="CustomRoleProvider" type="CustomProviders.CustomRoleProvider, 
     CustomProviders, Version=3.0.0.0, Culture=neutral, 
     PublicKeyToken=3563615169617648" applicationName="/"/>
  </providers>
</roleManager>

Now I have seen all sorts of explanations as to how solve the error that I mentioned earlier. Most of them seem to suggest that I add tags to my provider blocks. Some seem to suggest that I remove the role manager from the machine.config. And some still seem to suggest not removing or adding anything. This last approach does not seem to account that my web application is being run from IIS and not a local machine.

In the end, I have have tried these approaches to little avail. Can someone please explain to me how I can get passed this error? Thanks in advance!

Answer

Novice in.NET picture Novice in.NET · Jun 27, 2014

I got this error when using the default MVC 4 web application. I had to add the following to web.config and the error went away. Under <system.webServer> add

<modules>
 <remove name="RoleManager"/>
</modules>