Oracle 5.0 Reference Manual page 1890

Table of Contents

Advertisement

20.2.4.3. Tutorial: MySQL Connector/Net ASP.NET Session State Provider
MySQL Connector/Net from version 6.1 has included a MySQL Session State Provider. This provider
enables you to store session state in a MySQL database. The following tutorial shows you how to
prepare to use the MySQL Session State Provider, and then store session data into the MySQL
database. This tutorial uses Microsoft Visual Studio 2008 Professional Edition, MySQL Connector/
Net 6.1.1 and MySQL Server 5.1. This tutorial also assumes you have created an empty database,
for example test, where you will store session data. You could do this using the
interpreter.
1. In Visual Studio, create a new ASP.NET web site. If you are not sure how to do this, refer to
the tutorial
demonstrates how to do this.
2. Launch the MySQL MySQL Website Configuration tool. Due to a bug in 6.1.1, this may not appear
unless you are connected to a server in the Server Explorer. If you are unfamiliar with the MySQL
Website Configuration tool, consider first working through the tutorial in
Website Configuration
3. Navigate through the wizard to the Session State page. Make sure the check box Use MySQL to
manage my ASP.NET session data is selected.
4. On the same page, configure the connection string to the database that will contain your session
data. If this database is empty, MySQL Connector/Net will create the schema required to store
session data.
5. Ensure that the check box Autogenerate Schema is selected so that MySQL Connector/Net will
create the schema in your database to store the session data correctly.
6. Enter the name of your application.
7. Click Finish. The MySQL Website Configuration tool will now update your application's
web.config
this case, we have selected the MySQL Session State Provider.
At this point, you are ready to use the MySQL database to store session data. To test that the set up
has worked, you can write a simple program that uses session variables.
1. Open Default.aspx.cs. In the
Session["SessionVariable1"] = "Test string";
2. Build your solution.
3. Run the solution (without debugging). When the application runs, the provider will autogenerate
tables required in the database you chose when setting up the application.
4. Check that the schema was in fact created. Using the MySQL Command-Line Client use the target
database and then type
required schema automatically, as we selected this to happen in the MySQL Website Configuration
tool.
5. Now view the contents of these tables by typing
command interpreter. This will display the session data our application used. Note that this
mysql
is stored in binary format so some data may not display as expected.
At this point, you have installed the Session State Provider and carried out a preliminary test of the
installation. You will now work a bit more with the Session State Provider.
In this part of the tutorial, you will set and retrieve a session variable. You can work with your existing
project.
Connector/Net Tutorials
Section 20.2.4.6, "Tutorial: Databinding in ASP.NET using LINQ on
Tool".
file with information about the connection string and default providers to be used. In
TABLES;. You will see that MySQL Connector/Net has created the
SHOW
method, add the following code:
Page_Load
SELECT * FROM my_aspnet_sessions;
1870
command
mysql
Entities", which
Section 20.2.3.12, "MySQL
in the

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents