current viewrs count
-
hi, i want to know viewsrs count at a particular time who r viewing my site i hav tried this using global.aspx but no use plz help me thanks in adv
-
hi, i want to know viewsrs count at a particular time who r viewing my site i hav tried this using global.aspx but no use plz help me thanks in adv
ratnakar_ravi wrote:
i hav tried this using global.aspx but no use
How did you tried with
Global.aspx
, can you please put the code ofSession_Start()
Method.cheers, Abhijit My Recent Article : Beginner's Guide To View State
-
hi, i want to know viewsrs count at a particular time who r viewing my site i hav tried this using global.aspx but no use plz help me thanks in adv
-
Take a application level variable.Increase the count by 1 on every session start and Decrease when session ends in Global.asax.
Cheers!! Brij
and your session mode in global.asax must be set to InProc otherwise session_end event will not call.....
umerumerumer
-
hi, i want to know viewsrs count at a particular time who r viewing my site i hav tried this using global.aspx but no use plz help me thanks in adv
ratnakar_ravi wrote:
global.aspx
:confused: You can use Application variable to keep the current viewer count. Increase the count in Session_Start event and decrease it when the session ends. ASP.NET is multithreaded so application variables are not thread safe. Make sure you always use a lock around the operations. Something like
Application.Lock();
int currentViewerCount = int.Parse(Application["viewers"]);
Application["viewers"] = currentViewerCount + 1;
Application.UnLock();Navaneeth How to use google | Ask smart questions