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.