Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How i am find the lsit of all online user.

like Code project its show no of online user in top of the but not all online user friend lsit display

How i m doing this with session in Asp.net and other suggestion for solve this problem.



Thnks in advance
Posted

Write code in Global.asax file which interacts with the entire application.
The sample code is given below:
C#
void Application_OnStart(Object Sender, EventArgs E)
{
     Application["CurrentUsers"] = 0;
}
void Session_OnStart(object Sender, EventArgs E)
{
     Application.Lock();
     Application["CurrentUsers"] = System.Convert.ToInt32(Application["CurrentUsers"]) + 1;
     Application.UnLock();
}
void Session_OnEnd(object Sender, EventArgs E)
{
     Application.Lock();
     Application["CurrentUsers"] = System.Convert.ToInt32(Application["CurrentUsers"]) - 1;
     Application.UnLock();
}
 
Share this answer
 
Comments
H.Sohaib Ali 3-Aug-10 5:53am    
how to retrive value of CurrentUsers in asp.net(mean sDefault.aspx) pasge
Sandeep Mewara 3-Aug-10 6:24am    
using Application["CurrentUsers"]!!!!
You need a book if you didn't knew that Application is one of the state management techniques and it is at application level for all users.
H.Sohaib Ali 3-Aug-10 8:35am    
thnks for reply if u have any book or tutorial to give me a link
If you have a session, then you know someone is online. You have to wait for a time out to assume they are not. You can then count them
 
Share this answer
 
Comments
H.Sohaib Ali 2-Aug-10 17:06pm    
thanks for reply how to count session please some example to explain me ok sir
thanks for all for such a nice help i have solve my problem after a big time lol thnaks again
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900