Friday, October 20, 2006

A Session Data Loss problem (ASP.NET 1.1)

Today I am going to discuss about an issue that came up at one of our client site.

We developed an ASP.NET web application and deployed it at the client's place. We were using sessions to store data like User ID etc. If the session times out the session data will be lost and will result in automatic timeout for the user.

We came across a weird scenario,
Session timeout was set to 60 minutes. When the user come back to the site after 56 six minutes the session is extended. But if he leaves the browser like that for another 56 minutes, next time when he does any operation, the he was thrown out saying that the session is timed out.

We identified that this is not happening when the session is set to 20 minutes.

It took around 1 week for us to figure out what was going wrong.

The cause was that the data that was kept in the session was lost after 20 minutes of inactivity. This was because we were using "InProc" session state management.

This is apparently an ASP.NET issue (status is by design) for InProc session state type.
Ref: http://support.microsoft.com/default.aspx?scid=kb;en-us;324772

Actual cause was the for performance the application pool was configured to shutdown after 20 minutes of inactivity.
So in our case the worker process shuts down after 20 of inactivity. Hence all the data stored in Session will be lost.

Here is the solution that we used to get rid of the problem:

1. In the web.config change the session timeout settings (timeout="60") to 60 mins

2. In the IIS Management Console do the following:
AppPool configuration:
i. Select the AppPool that is configured for the web application
ii. Select Properties
iii. Go to the Performance tab
iv. Select the check box the "Shutdown worker processes after being idle for ( time in minutes):"
v. Change the value from 20 to 60 (It should be 60 or more)
Close the property window


I hope this solution would be helpful for somebody suffering from the same headache

0 Comments:

Post a Comment

<< Home