473,395 Members | 1,554 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,395 software developers and data experts.

Trap BrowserClose event so can Logout Session

How can I trap the user just closing the browser (upper right [x]) so I can
shutdown the Asp.net session properly. Don't really want to wait for the
default timeout to occur. I'm using a Master page so it should be easy to
logout once I know how to catch the event. Thanks.
Nov 5 '07 #1
3 1410
"Ron J" <rj******@atsecure.netwrote in message
news:eL**************@TK2MSFTNGP04.phx.gbl...
How can I trap the user just closing the browser (upper right [x])
You can't.

This question comes up regularly - there are usually several suggestions,
mainly centering around the onunload event of the <bodytag - none of them
even half works.

Don't waste any time on this - it isn't possible, otherwise every website in
the world would be doing it...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Nov 5 '07 #2
Thanks Mark. Fair enough. Perhaps you can suggest another way to do this:
User logs in at one station.
They move to another station and want to login.
We don't want concurrent logins from different stations.
-how do I logout the first one? I know timeout but thats 20minutes.

"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:Ow****************@TK2MSFTNGP05.phx.gbl...
"Ron J" <rj******@atsecure.netwrote in message
news:eL**************@TK2MSFTNGP04.phx.gbl...
>How can I trap the user just closing the browser (upper right [x])

You can't.

This question comes up regularly - there are usually several suggestions,
mainly centering around the onunload event of the <bodytag - none of
them even half works.

Don't waste any time on this - it isn't possible, otherwise every website
in the world would be doing it...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Nov 5 '07 #3
I suppose you could store the remote IP Address of the machine when they
first log in (you could store it in Cache with a key that matches the
username).

So if you look at the UserHostAddress inside Application_AuthenticateRequest
and compare, that would be one way to do it.
-- Peter
http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com

"Ron J" wrote:
Thanks Mark. Fair enough. Perhaps you can suggest another way to do this:
User logs in at one station.
They move to another station and want to login.
We don't want concurrent logins from different stations.
-how do I logout the first one? I know timeout but thats 20minutes.

"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:Ow****************@TK2MSFTNGP05.phx.gbl...
"Ron J" <rj******@atsecure.netwrote in message
news:eL**************@TK2MSFTNGP04.phx.gbl...
How can I trap the user just closing the browser (upper right [x])
You can't.

This question comes up regularly - there are usually several suggestions,
mainly centering around the onunload event of the <bodytag - none of
them even half works.

Don't waste any time on this - it isn't possible, otherwise every website
in the world would be doing it...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net


Nov 5 '07 #4

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

Similar topics

8
by: Zvonko | last post by:
Hi! Is it possible to capture an event when user leaves the page and execute some code? Not when he closes the window. Any ideas?
0
by: Ram | last post by:
I have a start page for my application default.htm which contains four frames. header.htm login.aspx rightside.htm footer.htm login.aspx conatins username, password fields and login button....
1
by: Feng | last post by:
Hi, Need help on the following issue. We need to clean up some session specific backend resource when a user ends his session. We have a "Logoff" button on the pages that handles that. But...
4
by: ad | last post by:
I use the Login controls of Asp.net 2.0 in my program. I want to logout a user by program, I try Session.Abandon() for this. But I found that the user is the same after I execute Session.Abandon()....
5
by: Chakravarti Mukesh | last post by:
Hi, I want to get an event if someone locks her/his computer so that I could do some finalizations before actually locking the system. For example how can I ensure that an user close a...
25
by: crescent_au | last post by:
Hi all, I've written a login/logout code. It does what it's supposed to do but the problem is when I logout and press browser's back button (in Firefox), I get to the last login page. In IE,...
1
by: joe | last post by:
Logout question I use a session to store the login information, say Session("Login") = success and use page_load to test the session("Login") success or not say If Session("Login") <success...
1
by: Kandiman | last post by:
Hiya, i made a asp page, and one of my divs (as a include) is as below. the problem is if the main page is resubmitted, i get logged out again?... heres the code.. i think its on the value=true...
1
by: phpuser123 | last post by:
Hi,I have created a script where I want to use onclick event and javascript to log out.Here r my coodes .. <script type="text/javascript"> function logout(){ <?php...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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...

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.