i have an issue regarding browser closing detection.i my asp.net application when user closes browser abruptlly i need to call a logout service which update loginstatus from true to false,i am doing this as below
function Logout() {
var Userid = $("#hdnfuid").val();
var branch = $("#hdnfbranch").val();
var service = LogoutService.Logout(Userid + "," + branch, SucceededCallback);
//alert(service);
}
function SucceededCallback(result) {
}
var isClose = false; ;
//this code will handle the F5 or Ctrl+F5 key
//need to handle more cases like ctrl+R whose codes are not listed here
document.onkeydown = checkKeycode
function checkKeycode(e) {
var keycode;
if (window.event)
keycode = window.event.keyCode;
else if (e)
keycode = e.which;
if (keycode == 116) {
isClose = true;
}
}
function somefunction() {
isClose = true;
}
function doUnload() {
if (!isClose) {
var selection = confirm('window is closing');
if (selection == true)
{var x=confirm("closing browser");
if(x==true)Logout();
else
return false;}
else {
return false;
}
}
but the problem is that when i click cancle of confirm box in that case also browser closes. i also need to call same service on session_end event of global.asax please suggest me the way of doing this. }
but the problem is that