Transferred from: http://www.cnblogs.com/epjnpe/archive/2007/12/05/984053.html
The following procedure is performed under Win 2003 SP2 + IIS 6.0, ASP. NET 2.0, SQL Server 2005.
1. Installing the Session Database
To the Framework directory
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
Run the following command:
Aspnet_regsql.exe-ssadd-sstype c-d [DB]-S [server]–e
-E is using Windows authentication, or you can use database authentication:
Aspnet_regsql.exe-ssadd-sstype c-d [DB]-S [server]–u [User name]–p [Password]
A session database is established in the specified database of the designated SQL Server server, which can be a separate database, which can be either a database used by a program or a name, and a default database name will be used. After the creation is complete, give the appropriate account permissions in SQL Server.
2. Modify the Web. config:
<sessionstate mode= "SQL Server" allowcustomsqldatabase= "true" sqlconnectionstring= "Data source=[server];initial Catalog=[db];user id=[user Name];p Assword=[password] "
Cookieless= "false"
Timeout= "/>"
If you use the default database name, as follows:
<sessionstate mode= "SQL Server" sqlconnectionstring= "Data source=[server];user id=[user Name];p Assword=[password] "
Cookieless= "false"
Timeout= "/>"
In this way, the session of the program will be stored in the database, one thing to note is that after this configuration, the object stored in the session must be serializable, if it is a custom class, then add the [Seriablizable] property.
Configuring the SQL Server Session method