Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How can I make sure that Session_End is called when the user closes the browser?

Reply
Thread Tools

How can I make sure that Session_End is called when the user closes the browser?

 
 
Annie
Guest
Posts: n/a
 
      09-13-2005
Hi guys,

I just want to do some clean up in the Session_End at Global.aspx.

However, if the user closes the browser window that event is not fired.

how can I call explicity protected void Session_End(Object sender, EventArgs
e)
when the user closes the browser window?



possible at all?



TA


 
Reply With Quote
 
 
 
 
JIMCO Software
Guest
Posts: n/a
 
      09-13-2005
Annie wrote:
> Hi guys,
>
> I just want to do some clean up in the Session_End at Global.aspx.
>
> However, if the user closes the browser window that event is not
> fired.
> how can I call explicity protected void Session_End(Object sender,
> EventArgs e)
> when the user closes the browser window?
>


Not possible. You're working with a connectionless architecture. The
server has no knowledge of when the user closes their browser.

--
Jim Cheshire
JIMCO Software
http://www.jimcosoftware.com

FrontPage add-ins for FrontPage 2000 - 2003




 
Reply With Quote
 
 
 
 
Hans Kesting
Guest
Posts: n/a
 
      09-13-2005
Annie wrote:
> Hi guys,
>
> I just want to do some clean up in the Session_End at Global.aspx.
>
> However, if the user closes the browser window that event is not
> fired.
> how can I call explicity protected void Session_End(Object sender,
> EventArgs e)
> when the user closes the browser window?
>
>
>
> possible at all?
>
>
>
> TA


The session does not end when the user closes the browser, but (default)
20 minutes after the last request to the site. (So if he was busy for 30 minutes
reading a single page, the session would have ended).

There is no (reliable) way to detect that the user has closed the browser,
navigated away from the site, or lost his internet connection.

Hans Kesting


 
Reply With Quote
 
KMA
Guest
Posts: n/a
 
      09-13-2005
which is why ebanking software has a "log out" button, so it can call
session abort.

"Hans Kesting" <> wrote in message
news:...
> Annie wrote:
> > Hi guys,
> >
> > I just want to do some clean up in the Session_End at Global.aspx.
> >
> > However, if the user closes the browser window that event is not
> > fired.
> > how can I call explicity protected void Session_End(Object sender,
> > EventArgs e)
> > when the user closes the browser window?
> >
> >
> >
> > possible at all?
> >
> >
> >
> > TA

>
> The session does not end when the user closes the browser, but (default)
> 20 minutes after the last request to the site. (So if he was busy for 30

minutes
> reading a single page, the session would have ended).
>
> There is no (reliable) way to detect that the user has closed the browser,
> navigated away from the site, or lost his internet connection.
>
> Hans Kesting
>
>



 
Reply With Quote
 
Annie
Guest
Posts: n/a
 
      09-14-2005
wow gettting very interesting!
How about catching it in client side using Javascript and something and
passing it to server somehow?
not possible at all?


"Annie" <> wrote in message
news:4326a30a$...
> Hi guys,
>
> I just want to do some clean up in the Session_End at Global.aspx.
>
> However, if the user closes the browser window that event is not fired.
>
> how can I call explicity protected void Session_End(Object sender,
> EventArgs e)
> when the user closes the browser window?
>
>
>
> possible at all?
>
>
>
> TA
>
>



 
Reply With Quote
 
JIMCO Software
Guest
Posts: n/a
 
      09-14-2005
Annie wrote:
> wow gettting very interesting!
> How about catching it in client side using Javascript and something
> and passing it to server somehow?
> not possible at all?
>


Sessions use a sliding expiration. That means that as soon as you "pass it
on to the server", you reset your Session expiration, thereby delaying the
execution of Session_End, not expediting it.

--
Jim Cheshire
JIMCO Software
http://www.jimcosoftware.com

FrontPage add-ins for FrontPage 2000 - 2003




 
Reply With Quote
 
JIMCO Software
Guest
Posts: n/a
 
      09-14-2005
Annie wrote:
> wow gettting very interesting!
> How about catching it in client side using Javascript and something
> and passing it to server somehow?
> not possible at all?
>


Hit Send too soon.

Of course you could have your browser call a page that calls
Session.Abandon, but you have to remember that there is no way to hook a
client side event ONLY when the browser is closed. It would be impossible
(as far as I can think right off this early in the AM) to detect the browser
closing correctly.

One more thing to add. Session_End is indeterminate. Even if you call
Session.Abandon, you cannot guarantee when Session_End will get called.

--
Jim Cheshire
JIMCO Software
http://www.jimcosoftware.com

FrontPage add-ins for FrontPage 2000 - 2003




 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make sure begin() const is called? saneman C++ 3 01-29-2008 07:32 PM
Session_End being called =?Utf-8?B?cmFtZW5kcmE=?= ASP .Net 1 01-17-2006 07:25 PM
Session_End called when project is rebuilt =?Utf-8?B?UENL?= ASP .Net 3 05-03-2005 02:27 PM
Session_End called when project is rebuilt =?Utf-8?B?UENL?= ASP .Net 0 05-02-2005 09:16 PM
Session_End does not fire when user closes browser Keith-Earl ASP .Net 4 11-15-2004 04:27 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57