The following process is performed under Win 2003 sp2 + IIS 6.0, ASP. NET 2.0, and SQL Server 2005.
1. Install the session Database
To the framework directoryC: \ windows \ Microsoft. NET \ framework \ v2.0.50727
Run the following command:Aspnet_regsql.exe-ssadd-sstype c-d [dB]-s [server]-e
-E uses Windows authentication or database Authentication:Aspnet_regsql.exe-ssadd-sstype c-d [dB]-s [server]-U [user name]-P [Password]
Create a session database in the specified database of the specified SQL Server server. It can be a separate database, that is, it can beProgramIf you do not specify the database name, a default database name is used. After the account is created, grant the corresponding account permissions in SQL Server.
2. modify web. config: sessionstate mode =" sqlserver " allowcustomsqldatabase =" true " sqlconnectionstring =" Data Source = [server]; initial catalog = [dB]; user id = [user name]; password = [Password] "
cookieless =" false "
timeout =" 20 " />
If the default database name is used:<SessionstateMode= "Sqlserver"Sqlconnectionstring= "Data Source = [server]; user id = [user name]; Password = [Password]"
Cookieless= "False"
Timeout= "20" />
In this way, the session of the program will be stored in the database. One thing to note is that after this configuration, the objects stored in the session must be serializable. If it is a custom class, the [seriablizable] attribute must be added.