Summary of the causes of Session failure and solutions to the loss

Source: Internet
Author: User
This article mainly introduces the summary of the reasons for Session failure. if you need some information, refer to the interview with GTSC yesterday. some interviewers asked me how to check the problem after Session loss. To be honest, so far, I have rarely encountered such a situation. The only thing I think of is Session timeout and Session reading and writing logs. I find that the interviewer is not very satisfied after hearing the logs!

In any case, it is a good opportunity to learn. today, I took the time to look up how to solve these problems on the Internet and summarize them. I hope they will help you.

By the way, the working principle of Session in asp is as follows:

Asp sessions are process-dependent. The ASP sessionstate is stored in the iisprogress, and the program inetinfo.exe is also used. 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.

Reference configuration:

Http://jingyan.baidu.com/article/22fe7ced78594f3002617f04.html

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. perform Session read and write logs. each read/write Session must be recorded, and the Session id, Session value, Page, current function, and function

Several Session operations, which makes it much easier to find the cause of loss

3. if this is allowed, we recommend that you use state server or SQL server to save the session, which is not easy to lose.

4. add the code to global. asa to record the creation time and end time of the Session. the 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, you should try to debug the script to check whether the Session is lost due to a script error.

The above content is a series of reasons why the session becomes invalid, which I hope to help you.

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.