By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,590 Members | 663 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,590 IT Pros & Developers. It's quick & easy.

Does a Session timeout Generate an event?

P: n/a
Is it possible to know when an asp.net session has timed out? Is there some
sort of timer event?

Thanks
Nov 18 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
CW
Put your code in the

Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the session ends
End Sub

handler of the global.asax file.

Same as in the ASP classic.

"David Laub" <dl***@wheels.com> wrote in message
news:ex**************@TK2MSFTNGP12.phx.gbl...
Is it possible to know when an asp.net session has timed out? Is there some sort of timer event?

Thanks

Nov 18 '05 #2

P: n/a
Session_OnEnd() in your global.asax file is called whenever the session
times out (or is abandoned explicitly).

-- Alex Papadimoulis
"David Laub" <dl***@wheels.com> wrote in message
news:ex**************@TK2MSFTNGP12.phx.gbl...
Is it possible to know when an asp.net session has timed out? Is there some sort of timer event?

Thanks

Nov 18 '05 #3

P: n/a
Thanks - but that just raises what I guess should have been my REAL
question:

Is there a way of detecting a "real" time out - i.e. the user of the web app
still has a page open in his/her browser, but didn't click a post-back for
20 minutes
versus the user explicitly closed the page/browser

what I specifically want is to display an error page on a time out - but if
just put unconditional code in Session_End, I'll have no way of knowing
what's an error and what isn't.
"CW" <a> wrote in message news:u$*************@TK2MSFTNGP10.phx.gbl...
Put your code in the

Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the session ends
End Sub

handler of the global.asax file.

Same as in the ASP classic.

"David Laub" <dl***@wheels.com> wrote in message
news:ex**************@TK2MSFTNGP12.phx.gbl...
Is it possible to know when an asp.net session has timed out? Is there

some
sort of timer event?

Thanks


Nov 18 '05 #4

P: n/a
David,

That can only be handled with client-side code. You'll need to use the
SetTimeout Javascript function. You'll probably need a work around to get it
to handle 20+ minutes, since i believe it works in miliseconds. But, that's
not a terrible deal, I'm sure you could figure it out.

--Alex Papadimoulis

"David Laub" <dl***@wheels.com> wrote in message
news:Oc*************@TK2MSFTNGP11.phx.gbl...
Thanks - but that just raises what I guess should have been my REAL
question:

Is there a way of detecting a "real" time out - i.e. the user of the web app still has a page open in his/her browser, but didn't click a post-back for
20 minutes
versus the user explicitly closed the page/browser

what I specifically want is to display an error page on a time out - but if just put unconditional code in Session_End, I'll have no way of knowing
what's an error and what isn't.
"CW" <a> wrote in message news:u$*************@TK2MSFTNGP10.phx.gbl...
Put your code in the

Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the session ends
End Sub

handler of the global.asax file.

Same as in the ASP classic.

"David Laub" <dl***@wheels.com> wrote in message
news:ex**************@TK2MSFTNGP12.phx.gbl...
Is it possible to know when an asp.net session has timed out? Is
there some
sort of timer event?

Thanks



Nov 18 '05 #5

P: n/a
CW
This is how I would do it.

Craft a cookie that expires, say, in 30 minutes (i.e., a non-persistent
cookie that times out later than a session cookie).

If your Session_start even handler, look for this cookie. If it is present,
then it indicates that user has timed out, but haven't closed the browser.

If the cookie doesn't exist, either it is because the user has not posted
back for 30 mins or the user closed browser (which would remove a
non-persistent cookie).

I guess you just have to determine what is an optimum time for the cookie
expiry time in order to distinguish between time-out vs browser closing.

HTH

"David Laub" <dl***@wheels.com> wrote in message
news:Oc*************@TK2MSFTNGP11.phx.gbl...
Thanks - but that just raises what I guess should have been my REAL
question:

Is there a way of detecting a "real" time out - i.e. the user of the web app still has a page open in his/her browser, but didn't click a post-back for
20 minutes
versus the user explicitly closed the page/browser

what I specifically want is to display an error page on a time out - but if just put unconditional code in Session_End, I'll have no way of knowing
what's an error and what isn't.
"CW" <a> wrote in message news:u$*************@TK2MSFTNGP10.phx.gbl...
Put your code in the

Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the session ends
End Sub

handler of the global.asax file.

Same as in the ASP classic.

"David Laub" <dl***@wheels.com> wrote in message
news:ex**************@TK2MSFTNGP12.phx.gbl...
Is it possible to know when an asp.net session has timed out? Is
there some
sort of timer event?

Thanks



Nov 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.