In your Global.asax
file you have Session_OnEnd()
public void Session_OnEnd()
{
// Set flag to 0
}
This will be okay if your sessionState
is set to INPROC
(Which is the default setting), if you have manually adjsuted it to StateServer
or SQL Server
then this event will be ignored.
When the browser closes the window you can do use onbeforeunload
in JavaScript
window.onbeforeunload = function(e) {
// call an Ajax function to reset the state.
};