Struggling with a persistent issue lately and really in need of some assistance. My goal is to perform a server-side callback to clear certain objects when the user navigates away from our page, without needing to click logout. Due to business requirements, our ASP.NET session timeout must be set at a high value. Additionally, I want to avoid using pop-up alerts or dialog boxes to prompt the user to return to the page and log off.
The solution I've come up with involves making an AJAX callback by embedding JavaScript into the page.
window.onunload = pageleave;
function pageleave() {
alert('test');
PageMethods.CheckLogout('abc','xyz',OnSucceed,OnFail);
}
However, there is a problem: For IE and Firefox, the unload event triggers, the alert is displayed, and my C# side callback functions as expected in all scenarios:
a) User closes browser
b) User enters a new URL in the address bar
c) User clicks on a link that causes the page to reload
In Chrome and Safari, cases a and b work correctly. Yet, when the user clicks on a link leading to the page reloading, my C# code does not execute. The JavaScript alert still pops up though.
I'm looking for ways to have Chrome/Safari behave like IE/Firefox in this regard. Is there a way to achieve this?
Thank you in advance for any assistance,
Rajesh.