473,788 Members | 2,733 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1429
"Ron J" <rj******@atsec ure.netwrote in message
news:eL******** ******@TK2MSFTN GP04.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**@markNOSPA Mrae.netwrote in message
news:Ow******** ********@TK2MSF TNGP05.phx.gbl. ..
"Ron J" <rj******@atsec ure.netwrote in message
news:eL******** ******@TK2MSFTN GP04.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_Aut henticateReques t
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**@markNOSPA Mrae.netwrote in message
news:Ow******** ********@TK2MSF TNGP05.phx.gbl. ..
"Ron J" <rj******@atsec ure.netwrote in message
news:eL******** ******@TK2MSFTN GP04.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
4161
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
1694
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. When the login is successful login page writes back javascript
1
2799
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 the problem is that sometimes the user still closing their browser window by clicking on the "x" button of the window. This is quite a problem for us because it will leave unreleased resource on the server for an unpredictable period of time,...
4
11241
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(). I thought that Session.Abandon() can break the connection of current user, but I fail How can I logout a user by program?
5
2512
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 particular application before locking her/his PC. Thanks Mukesh
25
3333
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, when I press back button, I get to the page that says "Page has Expired" but Firefox does not do this. I think it's something to do with sessions not properly unset or something like that but I haven't been able to figure it out. I am
1
7077
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 then response.redirect("LoginPage.aspx") But when i use logout to set Session("Login") = "" then redirect to LoginPage,
1
3327
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 for the hidden textbox on the logout sub.. but how do i get round this? can i not change the value onclick? <div id=Rightbody> <!--<form id="RightBodyForm" name="RightbodyForm" method="post" action="Guestbook2.asp">--> <% Response.Expires...
1
23213
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 session_destroy();?> } </script> <body> <a href="#" onclick="logout()">logout</a> </body>
0
9656
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10370
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10113
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9969
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8995
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7519
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5402
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.