ASP. NET modify/Delete station directory operation will result in session loss

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.