By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,984 Members | 1,386 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,984 IT Pros & Developers. It's quick & easy.

why does the amount of visitors not decrease?

P: n/a
Hi,

i want to get the amount of visitors online.
I did this in global.asax

I tested it by opening several browser sessions.
The amount increases, but never decreases, when i close some browsers.
I have heard of 'session.abandon' but have no idea where to put it (not in
Sub Session_End because it's not fired)
I don't want to use the session.timeout.

My web.config doesn't contain any session state of any kind.

Thanks for hints
Chris
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
Application("visitors") = 0
End Sub

Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
Application("visitors") = Application("visitors") + 1
End Sub

Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
Application("visitors") = Application("visitors") - 1
End Sub
Jun 8 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"Chris" <cc@dd.ddwrote in message
news:OB**************@TK2MSFTNGP04.phx.gbl...

Session_End fires when the session ends.

Closing the browser does *not* cause the session to end - this a very common
misconception.

If you want the number to decrease, you will have to force Session_End to
fire by calling Session_Abandon() - the usual way to achieve this is to have
some sort of "Log Out" button, but there is nothing you can do if the user
simply closes their browser...
--
http://www.markrae.net

Jun 8 '07 #2

P: n/a
Thanks for replying ..

Where have i do put that Session.abandon?
I mean: in which event (Page_UnLoad ?)
Thanks
"Mark Rae" <ma**@markNOSPAMrae.netschreef in bericht
news:ON*************@TK2MSFTNGP02.phx.gbl...
"Chris" <cc@dd.ddwrote in message
news:OB**************@TK2MSFTNGP04.phx.gbl...

Session_End fires when the session ends.

Closing the browser does *not* cause the session to end - this a very
common misconception.

If you want the number to decrease, you will have to force Session_End to
fire by calling Session_Abandon() - the usual way to achieve this is to
have some sort of "Log Out" button, but there is nothing you can do if the
user simply closes their browser...
--
http://www.markrae.net

Jun 8 '07 #3

P: n/a
"Chris" <cc@dd.ddwrote in message
news:eo**************@TK2MSFTNGP02.phx.gbl...
Where have i do put that Session.abandon?
I mean: in which event (Page_UnLoad ?)
You seem to be getting a bit confused with how ASP.NET pages work...

Page_Unload fires just after the page has been rendered into HTML and
streamed down to the client, not when the user closes the page:
http://msdn2.microsoft.com/en-us/library/ms178472.aspx
Do you have on-line banking? If so, then that website will (almost)
certainly have a "Log Out" button or hyperlink which they encourage you to
click rather than just closing your browser or moving to a different site -
the Session_Abandon() method goes there...

There is no way whatsoever for ASP.NET to know that a user has closed their
browser...
--
http://www.markrae.net

Jun 8 '07 #4

P: n/a
Ok, thanks again

"Mark Rae" <ma**@markNOSPAMrae.netschreef in bericht
news:ua**************@TK2MSFTNGP04.phx.gbl...
"Chris" <cc@dd.ddwrote in message
news:eo**************@TK2MSFTNGP02.phx.gbl...
>Where have i do put that Session.abandon?
I mean: in which event (Page_UnLoad ?)

You seem to be getting a bit confused with how ASP.NET pages work...

Page_Unload fires just after the page has been rendered into HTML and
streamed down to the client, not when the user closes the page:
http://msdn2.microsoft.com/en-us/library/ms178472.aspx
Do you have on-line banking? If so, then that website will (almost)
certainly have a "Log Out" button or hyperlink which they encourage you to
click rather than just closing your browser or moving to a different
site - the Session_Abandon() method goes there...

There is no way whatsoever for ASP.NET to know that a user has closed
their browser...
--
http://www.markrae.net

Jun 8 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.