I have an web app in C# and after 20 mins the session times out. I can’t change this because other apps use the same config.
So I am checking to see if the Session is NULL and if it is. It redirect and adds a QueryString with the Session ID. The problem I am having is when the Session times out the SessionID because NULL. Is there anyway to still get the sessionid after the timeout?
Thanks!
No, once the session is gone, it is gone for good.
However, if you have control over the web pages, you can create a keep-alive mechanism in javascript by calling back to a simple ping method in an ashx page that implements IRequiresSessionState. Will update with an example momentarily.
Here’s the javascript that we use (note that this warns the user about the timeout, but it could easily just perform a non-posting query):
In the above example, m_wSessionTimeoutWarningMinutes and m_wSessionExpiresInMinutes are set in server side code along with an initial call to ResetSessionTimeoutWarning().
ResestSessionTimeout performs an ajax request against an ASHX page that implements IRequiresSessionState just to keep the user’s session alive.