Home>

I went to the gtsc interview yesterday. Some interviewers asked me how to check the session after it was lost.To be honest,Rarely encountered such situations until now,The only thing that comes to mind is the session timeout, and there is a session to read and write logs,I found that the interviewer was not very satisfied after hearing it,sweat!

By the way, the working principle of session in asp:

ASP sessions are process-dependent.asp session state is stored in the iis process,This is the program inetinfo.exe.So when the inetinfo.exe process crashes,This information is lost.In addition, restarting or closing the IIS service will cause loss of information.

asp.net session implementation

asp.net's session is based on httpmodule technology,httpmodule can be used before the request is processed,State control of the request,Since the session itself is used for state maintenance,Therefore, using httpmodule as the session is the most suitable.

Reason 1:

The files in the bin directory were rewritten,asp.net has a mechanism,To ensure that the dll is recompiled,The system is running normally,It will restart the website process once,At this time, the session will be lost, so if any access database is located in the bin directory, or other files are overwritten by the system,Will cause session loss

Reason 2:

In the folder options,If you do not open the "Open folder window in a separate process", once you create a new window,The system may think that it is a new session and cannot access the original session, so this option needs to be turned on.Otherwise it will cause session loss

Reference configuration:

Reason 3:

It seems that most of the session loss is caused by the client,So start from the client,See if cookies are turned on

Reason 4:

Is there a problem with the session time setting?Will it be lost due to timeout

Reason 5:

Limit on the number of cookies in ie (20 cookies per domain) may cause session loss

Reason 6:

Use web garden mode and use inproc mode as a way to save sessions

Tackling lost experience

1. Determine whether it is caused by cause 1. When you refresh the page every time,Track modification time of a file in bin

2. Do session read and write logs,Record each read and write session,And to record the sessionid, session value, page, current function, first

Several session operations, it will be much easier to find the cause of the loss

3. If allowed,It is recommended to use state server or sql server to save the session, so it is not easy to lose

4. Add code in global.asa to record the creation time and end time of the session,Session loss caused by timeout can be recorded in sessionend.

5. If client script is used in some code,If JavaScript maintains the session state, you must try to debug the script.Is the session lost due to a script error?

php
  • Previous JS handling json date formatting issues
  • Next Summary of replace () in Javascript