In ASP.Net Web application i have to logout after browser is closed directly(All browsers like google chrome,IE and Firefox).Please suggest me any idea.
Asked
Active
Viewed 282 times
0
-
have you cnsidered making a ping every 5 seconds – Felix Farquharson Sep 12 '20 at 06:59
-
Trigger the logout in the `beforeunload` event: https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event – kol Sep 12 '20 at 07:14
1 Answers
0
Just giving an idea
If you will add an event listener to the window for example unload
it will fire for page reloads also. Try doing this and see if it is a good idea.
<body onUnload="signOut()">
Make signOut()
function redirect to Account/LogOff which is a built in method of ASP.net.
function signOut() {
$.ajax({
url: "/Account/LogOff",
success: function (result) {
// success
}
});
}
Now, when the tab or browser is closed, it will redirect to LogOff method and user will have to login again.

Mohammad Basit
- 971
- 6
- 18