Number of Visitors

T

TheOne

Hi I am trying to display on a web page number of visitors on the site. I am
doing this by increasing +1 in global.asax on Session_start and
subtracting -1 on Session_end. I am storing value in the
Application("numberOfVisitors"). It works fine but when I compare values to
number of ASP Applications "Sessions Active" under Windows 2003 performance
chart gives me different values. I am not sure why there is a difference,
and also if there is some better way of doing it? Is it possible in code to
count number of "Sessions Active" and display this instead of adding one and
subtracting one?

Thanks,

Sinisa
 
B

Ben Strackany

My guess is the Sessions Active perf counter is higher. If so, that would be
b/c IIS is counting all web visits as a session. For example, if you connect
to the web server to download an image, you won't invoke Session_start &
Session_end, but IIS may still consider your visit a "session".

However, instead of rolling your own visitor tracker, you could instead
write an ASP.NET page that displays any performance counter value you want.
So you could display "Sessions Active", "Current Connections", etc. in a web
page. You would do that via the PerformanceCounter objects in the
System.Diagnostics namespace.

I found a few articles that might help:
http://aspnet.4guysfromrolla.com/articles/041002-1.aspx
http://www.aspheute.com/english/20000809.asp
 
T

TheOne

Actually my counter is showing higher number than performance counter. For
instance It showing 260 on my web page but performance counter is showing 88
for number of active sessions. Is there some reason Session_end is not
getting fired so it is not subtracting -1 for number of sessions? I am using
in memory sessions

Thanks,

Sinisa
 
S

Steven Cheng[MSFT]

Hi Sinisa,

I think what you found is a reasonable behavior since there're also other
things may cause the Session_End not fire in additional to using
out-of-process SessionState. For example:

1. When the user's session is never used(store any data), that session is
keeping a random session which dosn't have a fixed sessionid( it will
change in each new request (postback)). So such session won't fire
Session_End event.

2. When we close the browser at client, the serverside also have no idea of
the clientside's status, so the session_end may not fire either.

In addition, here is a certain FAQ provide many of such questions on
ASP.NET sessionState, you can have a look to see whether it helps to
clarify the the problem:

http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&PostID=7504

HTH. Thanks,

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
T

TheOne

Is it more accurate than to use pref counter Sessions Active? We usually
have around 100-200 people visiting web site, and I need some counter that
is easy to implement and it approximately accurate? Are there some issues or
problems with pref counter Sessions Active?

Thanks,

Sinisa
 
S

Steven Cheng[MSFT]

Hi TheOne,

Thanks for your followup. I think the perf counter value is more accurate.
I'm not sure its detailed internal mechanism, but I'm sure it has its own
timeout mechnism no only rely on the Session_End. Also, I haven't found any
known issues or concerns on using performance counters on web page. Thanks,


Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,252
Latest member
MeredithPl

Latest Threads

Top