0

I have a website hosted on a live server where my session continue to be lost.

I have added some logging to my global.asax to check when application starts and ends and where session starts and ends as well as if there is an application error.

When i navigate to my website the application is started after i login a session is started and stores my email and user id's. after that i just navigated around my site for a minute or so and then im auto logged out. The auto logout is a result of session being null and then me abandoning it.

Below is my log of the test above.

[11:4:57:802]   Application has started
[11:4:58:872]   Session has started
[11:4:58:890]   Set Email Sessions
[11:4:59:61]   Set PracticeId and PractitionerId Sessions
[11:6:49:838]   Application has started
[11:6:5:391]   Session has ended
[11:6:5:445]   Application has ended
[11:6:8:208]   Session has started
[11:6:8:338]   Abandon Session
[11:6:8:343]   Session has ended

I have tested and this is not a problem to a specific link and this does not happen when running the site on local host. I lose my session because the application start is fired witch i assume then sets the sessions to null.

What could cause application_start to be triggered randomly?

Pomster
  • 14,567
  • 55
  • 128
  • 204

1 Answers1

0

Your IIS AppPool has configuration options that control recycling of the application.

For example: after a configurable period without any activity, when memory usage thresholds are exceeded, at a specific time every day, ...

Look at your AppPool configuration.

The auto logout is a result of session being null and then me abandoning it.

As for auto logout, if you are using Forms Authentication, then you don't need to auto log out just because your Session has expired. You'll still have the Forms Authentication cookie, whose expiry is completely independent of the Session expiry.

And in a well-designed application, you'll simply be able to regenerate whatever you had in Session by loading it from persistent storage (usually a database).

Joe
  • 122,218
  • 32
  • 205
  • 338