473,512 Members | 14,457 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Does a Session timeout Generate an event?

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
5 2022
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
2092
by: Alphonse Giambrone | last post by:
I am building a web app for users to add/edit data. They may add/edit several records during a session. When they are done (not necessarily immediately, could be 10 or more minutes later), I need...
4
10101
by: Keith-Earl | last post by:
I thought for sure Session End would fire when the user closes his browser, but no luck. The only way I can get the event to fire is to run a Session.Abandon, but is that really practicle? When a...
8
5470
by: bdeviled | last post by:
I am deploying to a web environment that uses load balancing and to insure that sessions persist across servers, the environment uses SQL to manage sessions. The machine.config file determines how...
11
2804
by: OldProgrammer | last post by:
All the documentation and discussion I have read indicate that the Session_End is not supposed to fire unless you are in "inProc" Session state mode, and then only on Session Timeout or at Session...
2
9670
by: Rajesh.jain25 | last post by:
Hi, I am facing a problem of automatic session timeout problem and automatic session_end event fired. Case1: As I have analyzed I get to know that the default session timeout is 20 in...
6
1248
by: Morten Snedker | last post by:
1,000 users log in for entering data. Which is the best way to clean up after each user? How do I end a session properly when an explicit logout is not an option? If the user just closes the...
2
3856
by: buu | last post by:
how could I handle session timeout event in asp.net? I would like to perform some action on database when it happens
1
2077
by: rockdale | last post by:
Hi: I have a web application which runs fine on our production server. But now when I install abother production server, it gets "System.NullReferenceException: Object reference not set to an...
3
2105
by: dmalhotr | last post by:
Hi, I would like to know if there was a way to trap a session timeout on an asp.net event. What I mean is that I've set a session timeout in the web.config file. What I would like to do is...
0
7373
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7432
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7094
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7519
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5677
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5079
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
452
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.