Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default Role Provider could not be found when using SimpleMembershipProvider

I'm trying to get authorization working on asp.net mvc4, so I try to use WebSecurity.

WebSecurity.InitializeDatabaseConnection("tradefairindia", "Users", "Id", "Username", false);

I've put this into Global.asax, and this is where the error comes, "Default Role Provider could not be found".

On the internet I read that I had to add this line of code to my web.config <roleManager enabled="true" defaultProvider="AspNetSqlRoleProvider">. But I had it added already because of previous errors.

How can I resolve this problem??

Edit:

When I change it to defaultProvider="SimpleRoleProvider" it gives me a new error. It says

The type or namespace name 'Data' does not exist in the namespace 'WebMatrix' (are you missing an assembly reference?)

like image 968
user1534664 Avatar asked Jul 31 '13 20:07

user1534664


1 Answers

I fixed it by changing the defaultProvider to SimpleRoleProvider. The second error I fixed by adding Webmatrix.data as a reference, and going to its property's and put copy local on true. I dont know how this fixes it, if anyone can elaborate that would be nice.

Here is my web.config for anyone who bumps into the same prob:

<system.web>
    //...
    <membership defaultProvider="SimpleMembershipProvider">
      <providers>
        <clear />
        <add name="SimpleMembershipProvider" type="WebMatrix.WebData.SimpleMembershipProvider, WebMatrix.WebData" />
      </providers>
    </membership>
    <roleManager enabled="true" defaultProvider="SimpleRoleProvider">
      <providers>
        <clear />
        <add name="SimpleRoleProvider" type="WebMatrix.WebData.SimpleRoleProvider, WebMatrix.WebData" />
      </providers>
    </roleManager>
    //...
</system.web>
like image 180
user1534664 Avatar answered Sep 30 '22 15:09

user1534664