Connector/Net Tutorials
1872
20.2.4.4. Tutorial: MySQL Connector/Net ASP.NET Profile Provider
This tutorial shows you how to use the MySQL Profile Provider to store user profile information in a
MySQL database. The tutorial uses MySQL Connector/Net 6.1.1, MySQL Server 5.1 and Microsoft
Visual Studio 2008 Professional Edition.
Many modern web sites allow the user to create a personal profile. This requires a significant amount
of code, but ASP.NET reduces this considerable by including the functionality in its Profile classes. The
Profile Provider provides an abstraction between these classes and a data source. The MySQL Profile
Provider enables profile data to be stored in a MySQL database. This enables the profile properties
to be written to a persistent store, and be retrieved when required. The Profile Provider also enables
profile data to be managed effectively, for example it enables profiles that have not been accessed
since a specific date to be deleted.
The following steps show you how you can select the MySQL Profile Provider.
1. Create a new ASP.NET web project.
2. Select the MySQL Website Configuration tool. Due to a bug in 6.1.1 you may have to first connect
to a server in Server Explorer before the tool's icon will display in the toolbar of the Solution
Explorer.
3. In the MySQL Website Configuration tool navigate through the tool to the Profiles page.
4. Select the Use MySQL to manage my profiles check box.
5. Select the Autogenerate Schema check box.
6. Click the Edit... button and configure a connection string for the database that will be used to store
user profile information.
7. Navigate to the last page of the tool and click Finish to save your changes and exit the tool.
At this point you are now ready to start using the MySQL Profile Provider. With the following steps you
can carry out a preliminary test of your installation.
1. Open your
web.config
file.
2. Add a simple profile such as the following:
<system.web>
<anonymousIdentification enabled="true"/>
<profile defaultProvider="MySQLProfileProvider">
...
<properties>
<add name="Name" allowAnonymous="true"/>
<add name="Age" allowAnonymous="true" type="System.UInt16"/>
<group name="UI">
<add name="Color" allowAnonymous="true" defaultValue="Blue"/>
<add name="Style" allowAnonymous="true" defaultValue="Plain"/>
</group>
</properties>
</profile>
...
Note that
anonymousIdentification
has been set to true. This enables users who have not
been authenticated to use profiles. They are identified by a GUID in a cookie rather than by user
name.
Now that the simple profile has been defined in
web.config
, the next step is to write some code to
test the profile.
1. In Design View design a simple page with the following controls:
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...