Akshay's Weblog

Quest for Oasis

Common reasons for the session loss issue in ASP.NET applications

Common reasons for the session loss issue in ASP.NET applications

Rate This
  • Comments 2

I have handled a lot of session related issues till now; I felt the need to key in a few checkpoints we could always refer while we are seeing session timeouts.

 

There are a lot of reasons for session loss. To name a few,

ü  Application Pool is recycled. - We will know this looking at the system logs

ü  IIS/worker process is restarted. - System logs will tell this as well

ü  Application Domain is restarted. - We need to monitor for application restarts for the ASP.NET counter in perfmon to check this. Few reasons for application restarts include

o   Bin folder of the application is touched by some application

o   Web.config or the machine.config is touched

o   Global.asax file is touched

o   Antivirus is running

ü  Something in the code is causing session loss, it can be anything. You will need to look into the code to have a fix on this.

ü  And many more..

 

Since we need to troubleshoot what's causing the session loss, we can proceed further if we can isolate things out here. The action items would be something as follows

1.    We need to know when the issue occurred the last time (probable date and time) and look at the system/application event logs from the server at this time.

 

2.    We need to enable the cookie logging in the IIS for the website and look in the logs for cookie loss. Also check for any uneven behavior such as OutOfMemory exception etc

 

3.    Exclude the antivirus scanning from the IIS/ASP.NET default folders and your application folders.

o   C:\WINDOWS\system32\inetsrv

o   C:\WINDOWS\assembly\GAC_32

o   C:\WINDOWS\Microsoft.NET\Framework\ (this should cover all versions of framework)

o   Any application directory containing web.config files, global.asa or global.asax, .net assemblies, and/or other web content which your web apps use

 

Please refer to the following article for more details,

Session variables are lost intermittently in ASP.NET applications

http://support.microsoft.com/kb/316148   

 

4.    Run the perfmon tool and add this counter “Application Restarts” (under ASP.NET counter). Keep it running until the next time the issue occurs.

5.    Please confirm with your application team that your code doesn’t make any modifications to the web.config file or the global.asax file or touch any dlls in the application’s BIN directory while the application is live.

6.    We could check if any particular page is causing the session timeout issue? If you notice that any particular page causes a lot of session timeouts, we can enable logging on this page to check what caused session timeout.

7.    Finally we could add the following entry which will be made in the master web.config of the 2.0 framework. (Refer to the section How do you determine what caused an appdomain restart? in http://blogs.msdn.com/tess/archive/2006/08/02/asp-net-case-study-lost-session-variables-and-appdomain-recycles.aspx)

 

However we cannot make this change in 1.1, the alternative is provided in the following article.

Logging ASP.NET Application Shutdown Events

http://weblogs.asp.net/scottgu/archive/2005/12/14/433194.aspx   

 

Please feel free to email me or leave a comment if I have missed something. I would be more than happy to include it J

 

-      Akshay

Leave a Comment
  • Please add 7 and 4 and type the answer here:
  • Post
Page 1 of 1 (2 items)