Are you just trying to end a user's session and close any database operations? If so, then you can use the Session_OnEnd in the global.asa file. This file would be stored in the root directory of your website application, but is not mandatory to be there.
Session ends after the specified last interation time (set in IIS > site properties > Directory > Configurations > app object - Session timeout) with the server. That means Session_OnEnd fires after a set time when the browser close.
But u can make both happen at once u can call a intermediate ASP page when you are loging out or closing the page. and in this page u can code like this
<% Session.Abandon %>
or any other database logic
this will force the session to end and will fire Session_OnEnd
Ok, here is an example that will take care of the refresh and form post. It will determine if the window is being closed via the "X" in the upper right corner or a hyperlink (#2) that has the ClosesWindow set to true.
You can add a location.href in the CheckWindowClosed function.
<html>
<head>
<Script language="javascript">
var ClosesWindow = true;
function CheckWindowClosed() {
// This code only fires when the window is closed when the
alert('Page Closed');
}
</script>
</head>
<body onBeforeUnload="if(ClosesWindow == true){CheckWindowClosed();}" onmouseover="ClosesWindow=false;" onmouseout="ClosesWindow=true;">
<a href="">Does not count as a window close</a> <br>
<a href="" onmousedown="ClosesWindow=true;">Counts as a closed window</a>
</body>
</html>
hmmm...maybe we can capture the screen coordinates and see if the mouse is outside the main window when the "Refresh" is performed. Let me do a little research on this too. I will post back in a few.
Yeah, I don't think there is a really clean way of doing this, although, I sort of like the frames method as you described.
Did you try posting in the JavaScript forum since this has much to do with JavaScript, more than ASP.
I suppose you could also give the user a confirmation window (then redirect if necessary) and let them decide if they would like to logout. I know that this would be annoying when they click on the refresh button, but in your application, do you anticipate the refresh button will be clicked a lot?
Thanks for the star and no problem. Have you considered posting to a separate ASP file and redirecting back after you processed the information? Would this alleviate any issues?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.