Http://www.jb51.net/article/21770.htm
Http://blog.chinaunix.net/uid-7425507-id-134216.html
After you modify the directory name using Directory.move (Olddir,newdir) in the Web project or delete the directory using Directory.delete (TRUE), the session is found to be invalid.
If deleting the changed directory is not part of the current project's virtual directory, the Session is available, but not available; the debug trace prompts: Session.get_item () ... returns null;
Deleting a directory in a virtual directory can cause the session to be lost and invalidated. And the essence of the session loss is: application Restart!
Here are a number of solutions:
1) Save session with external process
2) Save session with Database
3) The user ID is placed in a cookie, if the session is detected empty but the cookie exists in the reinitialization session.
4) The directory on which the operation will be moved out of the ASP.
First, the operation is as follows:
1. Start the ASP. NET State Service first, and if the service does not start, subsequent changes will not work.
If you want to enable the session state in StateServer, first enable the ASP. NET State Services (ASP) in Control Panel-Administrative Tools-services. and set this service to Automatic (auto-start)
2. Modify <sessionState/> Configure in Web. config as shown in the following code
In addition toWeb. configSettings in FileModeproperty isstateserverstateserver IP address and port number If in iis stateserver then address is 127.0.0.1, configured as follows
<sessionstate mode = " stateserver stateconnectionstring = tcpip=127.0.0.1:42424 " sqlconnectionstring =" data source=127.0.0.1; Trusted_connection=yes cookieless = false " timeout =" 40 />
Complete the above two points, even if the IIS restart, as long as the client's browser flag has not changed, the session is still valid.
3. If the above settings are not valid, you need to modify the registry:
[Hkey_local_machine\system\currentcontrolset\services\aspnet_state\parameters]
"Allowremoteconnection" =dword:00000001000
ASP. NET modify/Delete station directory operation will result in session loss