473,325 Members | 2,342 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Question about handling application close events

Hey guys out there,

I really need your help, i am building up a web site, so
for security reasons i need to do "some things" before the
user log off, and i indeed do it. Now the matter is that
any user can also CLOSE the page without logging off, and
by then i would need to be able to so "some things" (such
as save his log off time) and i need to do it before the
application get close, i have tried a hundred times to put
some code on the Global.asax file in the procedure
application_end or session_end, but it is like it never
passes through this peace of code. So, can you tell me
where to put the code i want to execute in the very moment
in which the application start closing? Thanks in
advantage,

Pierke
Nov 16 '05 #1
4 2928
Pierke,

The Session_End handler is the appropriate place to handle this sort of
action. However, this handler is only called when you a) explicitly close the
session in your code (e.g. in response to a user "log out" action which you
define), or b) when the session times out.

Note that if the client browser is simply closed without giving you the
opportunity to programmatically close the session, your Session_End handler
will not fire until the session times out. This is probably why you are not
seeing this event fire.

The timeout for the session can be modified in the web.config <sessionState>
tag timeout attribute (which is given in minutes), eg:

<configuration>
<system.web>
<sessionState mode="InProc" timeout="20" />
</system.web>
</configuration>

However it is not recommended to set this timeout too small (except when
testing your session end handler, where you could set it down to just 1
minute so you dont have to wait too long for it to fire when debugging) as
the session may start timing out whilst the user is still reading / working
on a single page.

Hope this helps,
Chris.

"Pierke" wrote:
Hey guys out there,

I really need your help, i am building up a web site, so
for security reasons i need to do "some things" before the
user log off, and i indeed do it. Now the matter is that
any user can also CLOSE the page without logging off, and
by then i would need to be able to so "some things" (such
as save his log off time) and i need to do it before the
application get close, i have tried a hundred times to put
some code on the Global.asax file in the procedure
application_end or session_end, but it is like it never
passes through this peace of code. So, can you tell me
where to put the code i want to execute in the very moment
in which the application start closing? Thanks in
advantage,

Pierke

Nov 16 '05 #2
As a suggested work-around for the logoff time question, how about
maintaining a "last user action" field instead? This could be used to
effectively monitor the last time the user interacted with the
application, either clicking a button, updating a field, or even
logging off.

I know it is not what you were asking, but it might reduce your
problems to remove one aspect.

On Tue, 12 Oct 2004 13:48:37 -0700, "Pierke"
<os**********@facinf.uho.edu.cu> wrote:
Hey guys out there,

I really need your help, i am building up a web site, so
for security reasons i need to do "some things" before the
user log off, and i indeed do it. Now the matter is that
any user can also CLOSE the page without logging off, and
by then i would need to be able to so "some things" (such
as save his log off time) and i need to do it before the
application get close, i have tried a hundred times to put
some code on the Global.asax file in the procedure
application_end or session_end, but it is like it never
passes through this peace of code. So, can you tell me
where to put the code i want to execute in the very moment
in which the application start closing? Thanks in
advantage,

Pierke


Nov 16 '05 #3

Chris,

Thanks a lot for what you told me. It was of great help, i indeed didn't
know the handler session_end was invoked when the session times out,
once the client has simply closed the browser without logging off. I
thought there was no way to access this handler in this case. I am
ashamed for being so ignorant, but i must admit i am kind of novice to
all this dotNet technology. You might even not believe me that it was
just two weeks ago when i first ran Visual Studio.net.
Now i can save the log off time of the user, although some minutes later
than he does, in case he doesn't log off properly of course. So once
more thanks you so much and good luck!!!
Pierke
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #4

Marc,
Thanks anyway, you are right this is not what i was asking but what you
suggest me is a very good idea as well. Trust me i would take in
serously into accound, since i am rather interested in the last time the
client interacted with the page than the time he logges off. At the
moment, i am making a decission upon whether to register the client log
off time OR the client last action time.
Well, have a nice day and thank for your help,
Pierke
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Eric Newton | last post by:
VB's more declarative nature of handling events is golden. I'm hoping C# will acquire this type of deal, in addition to the anonymous delegates. could do same as vb (actually would be easier to...
7
by: Michael C | last post by:
Hi all, I half-resolved my previous TreeView issue. Now I was wondering if anyone knows of a way to keep a TreeNode from being highlighted when it is left-clicked? It seems like there should...
1
by: Natalia DeBow | last post by:
Hi, I am working on a Windows-based client-server application. I am involved in the development of the remote client modules. I am using asynchronous delegates to obtain information from...
44
by: craig | last post by:
I am wondering if there are some best practices for determining a strategy for using try/catch blocks within an application. My current thoughts are: 1. The code the initiates any high-level...
1
by: Naveen Mukkelli | last post by:
Hi, I'm developing an class library. One of the classes raises some events. I'm testing this library by developing a test application. When I run two instances of this test application on the...
4
by: Macca | last post by:
Hi, I have an windows forms application that accesses a SQL database I have a few questions as to connecting to the database. This application will run 24 hours a day. It is a monitoring...
12
by: scsharma | last post by:
Hi, I am working on creating a webapplication and my design calls for creating main webform which will have menu bar on left hand side and a IFrame which will contain all the forms that are shown...
11
by: chopsnsauce | last post by:
Here's the example: Dim frm As New FORM1 Try frm.show Catch ex As Exception msgbox ex.message
5
by: Michael Moreno | last post by:
Hello, In a class I have this code: public object Obj; If Obj is a COM object I would like to call in the Dispose() method the following code: ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.