Wednesday, 11 February 2009

Losing session data on IIS

I had a problem with asp.net app losing session data. The same app was working like a charm on my local machine but after deploying to dev server it was throwing exceptions from time to time caused by missing session variables.

My webapp was using default sessionState settings with mode set to 'InProc' and it was configured to use default application pool. The problem was caused by the application pool using Web Garden with 5 worker processes. When using InProc mode the worker processes DO NOT share session data!

2 possible solutions:
  1. Configure application pool to use 1 worker process: in IIS Manager right click yout application pool > Properties > Performance > Web Garden section
  2. Use different session state mode e.g. state server or sql server (set in web.config)

3 comments:

Garry @ TriSys said...

Doh!
Yes, I just remembered this setting after doing a google search and finding your post.
Thank you for posting this reminder.

Garry@TriSys

John W. said...

Thanks for the data. I have been searching for this for months!

Ghellon said...

Thanks a lot.
This solved me a very heavy problem in a production environment.