tags:

views:

130

answers:

3

How to investigate what is causing Session expiry? I would like to give some advise to end-users who have the following problem with our website:

If Session("xxxx") Is Nothing Then say something.. WHY??

Can I add something to web.config to make sessions last longer or should I read the IIS log files to see why this happens?

+1  A: 

First session's are configured in web.config's <sessionState> element.

Also you can pick up session ending event (SessionStateModule.End) but note (1) this only works for in-process session management, and (2) you will need to record (in the session) when requests occur, so you can determine if it was a timeout or some other reason.

Richard
so what are the default sessionState settings? and what are recommended ones to make sure it remains alive well? can there be e.g. proxy/firewall causing issues?
Tom
+1  A: 

I think normally if a user does nothing for a period of time(no page refreshes etc) then the session will expire, otherwise it would just consume loads of resources on the server.

In classic asp there was a timeout you could set, not sure if its still there in asp.net or not.

If you don't want the session to expire while to user is looking at your site you could maybe put a meta refresh into your pages, or be a bit cleverer and use some kind of ajax timer that triggers and does a partial refresh on something

beakersoft
+1  A: 

You could put some code in your Global.asax file's Session_End method to help determine what went wrong, assuming you're running your session as InProc.

To increase your session length in IIS6, do the following:

  1. Open IIS
  2. Right-Click your website and choose properties
  3. Choose the Home Directory tab
  4. Click the Configuration button, in the Application Settings section
  5. Choose the Options tab
  6. Increase the Session Timeout value to whatever you want.
  7. Close everything and do and IISReset
AaronS