Hi there,
You can use the onunload event of the <body> tag to execute some JavaScript. For example:
Code:
<html>
<head>
<title>Unload Example</title>
</head>
<body onunload="JavaScript:alert('Hallo');">
<h1>Unload Example></h1>
</body>
</html>
This will pop up an alert box when you close the browser.
Instead of alert() you can open a new window that requests Logout.asp for example.
You should be aware of the limitations of this solution. First of all, it may still not work every time. Secondly, this can be a pain for dial-up users (so may not apply in an Intranet environment). Suppose someone with a dial-up connection browses to your site, requests a long page and then disconnects to read the page without being on-line. As soon as they close the browser, the popup will appear and they are asked to dial-in again. Not very user friendly.
Bottom line: you can't really be sure that Session_OnEnd will fire under every circumstance, so you should work around it. One thing I once did in a distributed Intranet (with dial-up connections), was to "logout" on EVERY page. We had an include file on every important page in our site that called Updatedatabase(UserID). This method would update the database to register every last hit a user made. This way, we could see at what time the user requested the last page. An "old" last date would indicate logout.
Not a perfect solution because it required some database overhead, but it worked for us.
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.