Summary of Asp.net session loss

Source: Internet
Author: User

Working principle of session in ASP:
ASP sessions are process-dependent. The ASP sessionstate is stored in the iisprocess, And the inetinfo.exeProgram. When the inetinfo.exe process crashes, the information is lost. In addition, restarting or disabling the IIS service will cause information loss.

Implementation of Asp.net session
The session of Asp.net is based on the httpmodule technology. The httpmodule can control the Request status before the request is processed. Because the session itself is used for status maintenance, therefore, it is more appropriate to use httpmodule for session.

Cause 1:
Files in the bin directory are rewritten. Asp.net has a mechanism. To ensure that the system runs normally after the DLL is re-compiled, it restarts a website process, which will cause session loss, therefore, if an Access database is in the bin directory or another file is rewritten by the system, session loss occurs.

Cause 2:
In the folder option, if the "Open folder window in a separate process" is not opened, once a new window is created, the system may consider it as a new session and cannot access the original session, therefore, you must enable this option. Otherwise, the session will be lost.

Cause 3:
It seems that most of the session loss is caused by the client, so you have to start from the client to see if the cookie has been opened.

Cause 4:
Is there a problem with the session time settings? Will it be lost due to timeout?

Cause 5:
The maximum number of cookies in IE (20 cookies per domain) may cause session loss.

Cause 6:
The Web garden mode and inproc mode are used to save the session

solving lost experiences
1. determine if it is caused by cause 1. You can track the modification time of a file in the bin every time you refresh the page.
2. for session read and write logs, each read and write session must be recorded, and the session operations of sessionid, session value, page, current function, and function must be recorded, in this way, finding the cause of loss is much easier
3. if yes, we recommend that you use state server or SQL Server to save the session, which is not easy to lose
4. in global. Code is added to the ASA to record the session creation time and end time. session loss caused by timeout can be recorded in sessionend.
5. If some code uses client scripts, such as JavaScript to maintain the session Status, try to debug the script. Is the session loss caused by a script error?

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.