Mujadid Mughal
Mujadid Mughal

Reputation: 2663

ASP.NET Session Recycles

In an ASP.NET website we are storing sessions in SQL Server. All is working fine except that sessions frequently recycle. I've a timeout period set to 30 minutes but some times it recycles within a few minutes. We've a dedicated server, and website running under a 'classic' application pool. I've searched a lot on this problem, but didn't find a satisfactory answer. Any help will be greatly appreciated.

Note: mostly it happens on a page where there is lots of use of viewstate, I'm curious that is there a link of viewstate with session recycling?

Upvotes: 2

Views: 313

Answers (1)

competent_tech
competent_tech

Reputation: 44941

We've experienced this problem when we either have a web farm (more than one web server servicing clients) or a web garden (more than one worker process in an application pool).

If you have a web farm, then you need to ensure that all web servers have the same machine key and that all instances have the exact same application path.

If you have a web garden, try dropping the maximum worker processes back to 1 to see if that resolves the issue.

While you are checking the IIS settings, you should probably also ensure that the application pool is not recycling regularly. This can be due any of the following specified in the app pool:

1) Private Memory Limit (the app pool is reset if the maximum amount of memory has been exceeded)

2) Regular Time Interval recycling (the app pool is automatically recycled after a specified number of minutes, defaulting to 1740, and/or at specific times).

3) Idle Time-out (the number of minutes of inactivity that can elapse before the application pool is automatically shutdown).

You should also check the event logs for reports of the application pool crashing or otherwise being recycled.

Update:

An additional thought:

If you have an application, such as anti-virus or backup software, that monitors your application's bin directory and modifies or changes attributes (such as the backup flag or timestamp) of files in that directory OR your web.config file, this will cause application recycling as well.

Upvotes: 2

Related Questions