for many reasons you should stuck with MySQL on small to medium sized asp.net application. MySQL is always provided free of charge on shared hosting packages , if not , dozens are completely free of charge .
refer to this article for more details about about MySql different engines (requires registration) .
On Part 1 i will simply show how to instantly start using MySQL for securing your website members area using MySQL 5 native membership provider.
steps :
- download MySQL connecter , version 5.2 of the connector is robust !
- copy MySql.Data .dll and MySql.Web.dll to Bin. *
- membership provide is completely implemented on this version , use autogenerateschema="true" on web.config then running the "ASP.NET Configuration" will create the database schema for you. (website menu on Visual Studio).
membership section on web.config shown on step 4. - the whole bunch of providers configuration looks like *:
<roleManager enabled="true" defaultProvider="MySQLRoleProvider">
<providers>
<add connectionStringName="LocalMySqlServer" applicationName="/"
name="MySQLRoleProvider" type="MySql.Web.Security.MySQLRoleProvider, MySql.Web,Version=5.2.2.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</providers>
</roleManager>
<membership defaultProvider="MySQLMembershipProvider">
<providers>
<add name="MySQLMembershipProvider" type="MySql.Web.Security.MySQLMembershipProvider, MySql.Web, Version=5.2.2.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="LocalMySqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="/" requiresUniqueEmail="false" passwordFormat="Clear" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="3" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression="" autogenerateschema="true"/>
</providers>
</membership>
<profile defaultProvider="MySQLProfileProvider">
<providers>
<add name="MySQLProfileProvider" type="MySql.Web.Profile.MySQLProfileProvider, MySql.Web,Version=5.2.2.0,Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="LocalMySqlServer" applicationName="/" />
</providers>
</profile> - run ASP.NET configuration , start adding users/roles and secure member's area.

* if you used the connector installer,these configurations will not appear on your web.config, but can be located on machine.config. copy them into your own web.config (Binaries also can be located on C:\Program Files\MySQL\MySQL Connector Net 5.2.2) , we don't expect them installed on the hosting server !
Enjoy MySql as much as you can ! it's free, lite and supported by Sun and the community.
on Part 2 of this series i will be showing the de facto blog tutor, we will build a simple blog without having to deal with MySql delicate using ActiveRecord OR/M. till then !

2 comments:
Hi there,
I'm a novice on ASP.Net and MySQL too. I really need to understand this article, but I don't :S
Please help me. I'm getting crazy.
- I've already installed MySQL connector 5.2.5
- I've found MySql.Data.dll and MySql.Web.dll at "C:\Program Files\MySQL\MySQL Connector Net 5.2.5\Binaries\.NET 2.0" and "C:\Program Files\MySQL\MySQL Connector Net 5.2.5\Web Providers", respectively.
-- Where is the "Bin directory" where I need to put this 2 files??
-- On web.config, where do I need to implement the "autogenerateschema="true" property??
Thanks a lot. I (really) hope you can help me
Mena
Post a Comment