When a user is doing a page refresh/F5 the application is throwing session time out. this is due to the logout method is called on bodyUnload. We need the bodyUnload method if the user tries to close the application or Alt+F4 for clearing the session.
Please let me know how to detect the page refresh and stop calling the bodyunload method while page refresh.
seems detecting specific action of window close or refresh is not possible.
Try this trick at serverside:
>from ur bodyUnload call server to clear session not directly but after waiting certain time interval(as a task).
>if its refresh, request will ping server again, now this time u get chance to cross check sessionId with session
in clearing task and u can abort the operation.
Siva Shanmug...
0 Points
1 Post
How to detect Page refresh in MVC2
Nov 12, 2012 03:41 AM|LINK
Hi All,
When a user is doing a page refresh/F5 the application is throwing session time out. this is due to the logout method is called on bodyUnload. We need the bodyUnload method if the user tries to close the application or Alt+F4 for clearing the session.
Please let me know how to detect the page refresh and stop calling the bodyunload method while page refresh.
Thanks,
Siva
pvinita
Member
210 Points
99 Posts
Re: How to detect Page refresh in MVC2
Nov 12, 2012 04:43 AM|LINK
Hi Siva,
Try this..
<script language=javascript>
document.onkeydown = function(){
if(window.event && window.event.keyCode == 116)
{ // Capture and remap F5
window.event.keyCode = 505;
}
if(window.event && window.event.keyCode == 505)
{ // New action for F5
return false;
// Must return false or the browser will refresh anyway
}
}
</script>
i hate asp.net, try something new
raju dasa
Star
14412 Points
2452 Posts
Re: How to detect Page refresh in MVC2
Nov 12, 2012 06:39 AM|LINK
Hi,
seems detecting specific action of window close or refresh is not possible.
Try this trick at serverside:
>from ur bodyUnload call server to clear session not directly but after waiting certain time interval(as a task).
>if its refresh, request will ping server again, now this time u get chance to cross check sessionId with session
in clearing task and u can abort the operation.
//I dont have any code for that.
rajudasa.blogspot.com || blog@opera