471,344 Members | 1,334 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,344 software developers and data experts.

how to find total current users at site

Hi All,
We have a requirement to display total number of current users using the
site. We want to display only the total no other information. And this value
needs to change dynamically.

Is it possible to do this? Please let me know how to do it.

Thanks.
Jul 23 '05 #1
2 2279
have an application variable that gets incremented on session on start and
decremented on session on end. If you want it dynamic without a postback
you'll need to use something like ajax

http://weblogs.asp.net/mschwarz/arch...07/397504.aspx

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

"msnews" <an******@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Hi All,
We have a requirement to display total number of current users using the
site. We want to display only the total no other information. And this
value
needs to change dynamically.

Is it possible to do this? Please let me know how to do it.

Thanks.

Jul 23 '05 #2
That's a difficult number to calculate. You could keep a counter of the
number of sessions, if you are using session state. However, if you have
more than a few users, session state may affect your overall scalability.

There are probably online companies that have set up this infrastructure.
You may want to look to them, and buy the service.

On the other hand, you could write code to count current users. Warning:
this solution is sub-optimal for high-traffic sites. If you have a
high-traffic site, I'd suggest using an HTTP Module to count hits. However,
for the average sites, this will do:

Set up your code to access a singleton where you keep a list of IP addresses
that have accessed your site, and the time of day the hit occurs. Create a
windows service that calls a page on your site once every second as well.
On every hit, see if the IP address is in the list. If not, add it and set
the time. If so, reset to the current time. Then, scan the list, dropping
every IP address that is older than X seconds (I'd suggest 300 seconds).

To display the current number: You can place a control on a page somewhere
that uses XMLHTTP to go back to the server, on a regular basis, and get the
current count from the list. That way, the number will change dynamically.
See Ajax.Net for a control that is already wired to do this.

Good luck

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"msnews" <an******@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Hi All,
We have a requirement to display total number of current users using the
site. We want to display only the total no other information. And this
value
needs to change dynamically.

Is it possible to do this? Please let me know how to do it.

Thanks.

Jul 24 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by fwells11 | last post: by
6 posts views Thread by KS | last post: by
6 posts views Thread by John Dalberg | last post: by
7 posts views Thread by Kesavan | last post: by
2 posts views Thread by karinmorena | last post: by
10 posts views Thread by CodeNoob | last post: by
reply views Thread by Ronak mishra | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.