ASP.NET Membership/Role providers for MySQL?
Got it figured out! Using version 6.2.2.0 of MySql Connector/Net, follow these steps...
- Add reference to MySql.Web.dll
Change your
<membership>
in web.config to this:<membership defaultProvider="MySqlMembershipProvider"> <providers> <clear/> <add name="MySqlMembershipProvider" type="MySql.Web.Security.MySQLMembershipProvider, MySql.Web, Version=6.2.2.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" autogenerateschema="true" connectionStringName="NAME_OF_YOUR_CONN_STRING" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression="" applicationName="/" /> </providers></membership>
- Run the Project | ASP.NET Configuration tool and click on the Security tab to test
- Tested on ASP.NET 3.5, MySQL Server version 5.1, Windows XP 64-bit
The original question didn't specify which version of ASP.NET & MVC was used. With the recent release of .NET 4.5 and MVC 4 I hit the same problem as the OP but with the new technologies. This is my quick fix for it mostly the same config as Josh Stodola's answer but with some additional steps.
<membership defaultProvider="MySqlMembershipProvider"> <providers> <clear /> <add name="MySqlMembershipProvider" type="MySql.Web.Security.MySQLMembershipProvider, MySql.Web, Version=6.5.4.0, PublicKeyToken=c5687fc88969c44d" autogenerateschema="true" connectionStringName="*NAME_OF_YOUR_CONN_STRING*" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression="" applicationName="/" /> </providers></membership>
Get the AccountController and Views working:
- Delete the MVC 4 AccountController, AccountModels, Account view folder and _LoginPartial shared view
- Create a new MVC 3 web application
- Copy the MVC 3 AccountController, AccountModels, Account view folder and _LogOnPartial shared view into your MVC 4 application
- Replace
@Html.Partial(“_LoginPartial”)
in the shared _Layout view with@Html.Partial(“_LogOnPartial”)
I've did this with asp.net but I think it could be used for mvc too: hasangursoy.com.tr/aspnet-authorization-authentication-with-mysql