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?)
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With