asp.net modify/delete Site Directory operation after session loss problem _ practical skills

Source: Internet
Author: User
It was later found that if the deleted directory does not belong to the virtual directory where the current project is located, the session is available, but the session is not available; the prompt in the debug trace: Session.get_item (). returns null;
After the study found that the virtual directory to delete changes to the directory will cause session loss, so that the failure. and the essence of 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 to be empty but the cookie exists in the reinitialization session.
4 The directory to be operated on will be removed from the ASP.net program

I use the first one here, the operation is as follows:
1. Start the ASP.net state service first, and the subsequent changes will not work if the service does not start.

2. Modify <sessionState/> configuration in Web.config as shown in the following code
Copy Code code as follows:

<sessionstate
Mode= "StateServer"
Stateconnectionstring= "tcpip=127.0.0.1:1314"
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 browser is not changed, the session is also valid.

3. If the above settings are still invalid, you need to revise the registry:
[Hkey_local_machine\system\currentcontrolset\services\aspnet_state\parameters]
"Allowremoteconnection" =dword:00000001000

Note: If you want to store the object in session, add the [Serializable] property to the class, even if the object is serializable.
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.