Recently, I was working on a business system. During the project, I found that I had to constantly modify the system, compile the system, and log on to the system. I found that the repetitive work was too heavy.
The session of the Asp.net program is saved in the IIS process by default. When the bin directory file compiled by the project is rewritten, the IIS process restarts and the session is naturally lost, of course, you have to log on again.
Therefore, the session is saved to other places by configuration. In Asp.net, the session is saved in the following ways: IIS process (default), StateServer, database, and custom mode. In StateServer mode, I configure ASP to be saved on the local machine.. Net Status Service, successful, but want to save to other machines is always failed, I do not know why, is saved in the local ASP. in the net status service, the address of the target machine in stateconnectionstring can only be localhost or 127.0.0.1. if I change it to my machine name or IP address of the LAN, it will not work. Later, I only need to configure it to the database.
First, you need to create a status database (this is simple), and then generate tables, stored procedures, and other things of the status database. Run the following command at the. NET prompt:
D: \ Program Files \ Microsoft Visual Studio 8 \ Vc> aspnet_regsql-ssadd-s 192.168.0.
200,1533-U sa-P Sa-D asp_state-sstype C
Start adding session status.
..
Completed.
To use this custom session status database in a web application, specify it in the configuration file
Use "allowcustomsqldatabase" and "sqlconnecti" in the <system. Web >\< sessionstate> section
Onstring attribute.
Create an urban management database Association. Modify the Web. config file as follows:
<Sessionstate mode = "sqlserver" allowcustomsqldatabase = "true" stateconnectionstring = "TCPIP = 127.0.0.1: 42424"
Sqlconnectionstring = "Data Source = 192.168.0.223; database = asp_state; uid = sa; Pwd = sa"/>
After this is done, you do not need to log on again when compiling the code, and the database is saved on another machine. Even if my machine restarts, you do not need to log on again (of course, when the session has not expired, sqlserver has a job that regularly deletes expired session records) because the session status information has been saved in the database ..