-1

I use below setting in web.config

<sessionState mode="InProc" cookieless="false" timeout="10"/>

...

<authentication mode="Forms">
<forms loginUrl="login.aspx" timeout="10"/>

and in Session_End according to Session's value i change a column's value in database (if this column's value is 1 means user online) but sometimes after a day that user close browser this column's value steel is 1 (means Session_End doesn't call after user close browser)

Hans Kesting
  • 38,117
  • 9
  • 79
  • 111
SajjadZare
  • 2,487
  • 4
  • 38
  • 68

2 Answers2

1

No event will be called if your browser is closed, it will be called after timeout.

The event should be called, but not necessarily right after the timeout.

You could try from a Browser: Start a session,wait > 1 minute, do a Postback somehow

This should help to verify that the Timeout works and I think you will also see the SessionEnd happening at that time. Otherwise, just wait and start some other sessions. The system will come around o calling it sometime.

http://forums.asp.net/t/1689960.aspx/1

Nipun Ambastha
  • 2,553
  • 1
  • 16
  • 26
0

No Session_End will not call on page close. You need to use script for that

<script>    
window.onbeforeunload = function (evt) {
var message = ‘Are you sure you want to leave?’;
if (typeof evt == ‘undefined’) {
evt = window.event;
}
if (evt) {
evt.returnValue = message;
}
return message;
}

</script>

Using this script you can identify when user closes the browser

Darshan
  • 535
  • 1
  • 3
  • 16
  • 1
    Try this carefully: the browser just sees that you are leaving this page, which also happens when you navigate to another page in your site, or even cause a postback. – Hans Kesting Apr 05 '13 at 09:07
  • Correct..but requirement of the questioner is like this – Darshan Apr 05 '13 at 09:38