Losing Session State

Viewed 126815

I have an ASP.net application where Users aren't able to successfully complete certain actions, for reasons, I'm assuming, can only be related to losing their session (which is where I maintain their current user information, and how determine whether they are logged in)

I'm at a loss as to why they would lose their session, so my first question is:

What (in general) would cause a user to lose their session in ASP.net?

and since I don't know when a user loses their session and can't reproduce it myself:

How can I track when I user loses their session

Below is my sessionState config for reference

<sessionState
           mode="InProc"
           cookieless="false"
           cookieName="My.Site.Com"
           timeout="480"/>
11 Answers

Dont know is it related to your problem or not BUT Windows 2008 Server R2 or SP2 has changed its IIS settings, which leads to issue in session persistence. By default, it manages separate session variable for HTTP and HTTPS. When variables are set in HTTPS, these will be available only on HTTPS pages whenever switched.

To solve the issue, there is IIS setting. In IIS Manager, open up the ASP properties, expand Session Properties, and change New ID On Secure Connection to False.

I had same problem by losing sessions. every time , every page reload, my sessions clear and by new reload any page, my sessions returned by valid value...

i fixed it by change MaximumWorkerProcesses from 0 to 1 in iis

I was struggling with this issue for 14 days.

Here's what helped me:

  1. Check your recycling options in App Pool > Advanced settings. Turn off all of the options so it won't recycle on its own.
  2. Check your web.config file for the executionTimeout property under httpRuntime and increase its value.
  3. Check your web.config file for the timeout property under sessionState and increase its value (I set it to 300 minutes).
  4. Go to the server's event log and check the Application log for unhandled exceptions that may cause the worker process to crash. Fix them in your code or use try and catch to eliminate this crash.
  5. Try changing the value of your maximum worker process from 0 to 1 or the other way around, this may also solve this issue.

In my case, session state was loosing due to Load Balancer. Session was storing in one server and Load balancer was redirecting next call to another server where session state was missing.

Related