how can i make work the code blocks when session expired on ASP.NET c# ? i want to do something like
if(session==expired)
{
//do something
}
or just want to ask. if (browser is closed) do something; thank you a lot
how can i make work the code blocks when session expired on ASP.NET c# ? i want to do something like
if(session==expired)
{
//do something
}
or just want to ask. if (browser is closed) do something; thank you a lot
In Internet explorer, there is an onUnload
event of the body. Mozilla event here: https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload
However, the event only detects the ‘X’ on the browser. If user terminates the process, the event isnt called.
Try the following code:
Client side
client side script:
<body onbeforeunload="window.open('http://www.yourwebsite.com/backend.aspx','mywindow','width=10,height=10');">
In backend:
Code behind Page_Load
Session.Clear();
Session.Abandon();
Response.Redirect("Login.aspx");
}
Reference: C# Clear Session