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

若如初见. 提交于 2020-01-22 15:27:06

问题


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!


回答1:


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>



回答2:


Two things:

enabled="false" should probably be enabled="true"

And I'm not convinced the applicationName="/" is helpful, but it may not be hurting, either.




回答3:


I got this error message when adding an application in IIS 8 to our existing web site (Right-click on the website in IIS, select "Add Application"). The application's web.config only had the default tag, which was removing the default provider that the web site's web.config defined.

I removed the RoleManager tags completely from the application's web.config, and then the website and application started working properly.



来源:https://stackoverflow.com/questions/16857825/default-role-provider-could-not-be-found-on-iis-7-running-net-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!