Wednesday, April 20, 2011

Enable ASP.NET Web Site Administration Tool with MariaDB on MVC3

(continued from phosphorescence: Create Simple MVC 3 App with VWDExpress and MariaDB)
If you want to use the system built in ASP.NET with MariaDB, you should do some configurations. This article is referring this article.

Create schema for aspnetdb on MariaDB

Like in this post, create the schema named as aspnetdb and special user for aspnetdb schema.



Check some config files

At first, check containing XML elements like below in C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config file.

........
<add name="LocalMySqlServer" connectionString="" />
........
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.3.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
........
<add name="MySQLMembershipProvider" type="MySql.Web.Security.MySQLMembershipProvider, MySql.Web, Version=6.3.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="LocalMySqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Clear" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression="" />
........
<add name="MySQLProfileProvider" type="MySql.Web.Profile.MySQLProfileProvider, MySql.Web, Version=6.3.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="LocalMySqlServer" applicationName="/" />
........
<add name="MySQLRoleProvider" type="MySql.Web.Security.MySQLRoleProvider, MySql.Web, Version=6.3.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="LocalMySqlServer" applicationName="/" />
........
If these lacked, re-install Windows Installer of MySQL Connector/Net(see this post).

At second, in C:\Windows\Microsoft.NET\Framework\v4.0.30319\ASP.NETWebAdminFiles\App_Data\GroupedProviders.xml, add elements like below:

        <GroupedProvider name="MySQLProvider">
            <MembershipProvider name="MySQLMembershipProvider" />
            <RoleProvider name="MySQLRoleProvider" />
        </GroupedProvider>


At last, in Web.config on your project, add these elements into each corresponding elements.

........
    <add name="MySQLApplicationServices"
         connectionString="server=localhost;port=3306;User Id=aspnetdb_user;password=somepassword;Persist Security Info=True;database=aspnetdb"
         providerName="MySql.Data.MySqlClient" />

........
          <add name="MySQLMembershipProvider"
               type="MySql.Web.Security.MySQLMembershipProvider"
               autogenerateschema="true"
               connectionStringName="MySQLApplicationServices"
               enablePasswordRetrieval="false"
               enablePasswordReset="true"
               requiresQuestionAndAnswer="false"
               requiresUniqueEmail="false"
               maxInvalidPasswordAttempts="5"
               minRequiredPasswordLength="6"
               minRequiredNonalphanumericCharacters="0"
               passwordAttemptWindow="10"
               applicationName="/" />

........
          <add name="MySQLProfileProvider"
               autogenerateschema="true"
               type="MySql.Web.Profile.MySQLProfileProvider"
               connectionStringName="MySQLApplicationServices"
               applicationName="/" />

........
        <add name="MySQLRoleProvider"
             autogenerateschema="true"
             type="MySql.Web.Security.MySQLRoleProvider"
             connectionStringName="MySQLApplicationServices"
             applicationName="/" />

........

Make default browser IE

If you set the default browser Firefox, Opera and so forth and not want to make system default browser IE, you can make default browser IE for only VWDExpress web applications. At first, make a *.aspx file on project root.
Then, right click this *.aspx file, select "Browse with..." menu and select IE as default browser.

At last, you may delete previous *.aspx file.

Enable ASP.NET Web Site Administration Tool

At first, Add DLLs for "MySql.Web" and set "local copy" property of it to "True".
So let's select [Project]-[ASP.NET configuration] menu. ASP.NET Web Site Administration Tool is launched in IE.

Move to the provider page by clicking "Provider" tab menu, select radio button for MySQLProvider and click test.
Move to the security page by clicking "Security" tab menu, enable the role, then create roles and users as you want.
Let's check there are many tables on aspnetdb schema.

No comments:

Post a Comment