ASP.NET - How to track no. of users in asp.net c# application

Asked By myzonal.com myzonal.com on 16-Apr-10 05:28 AM
Hi All

I have developed a web application and upload in the server.we want that when any user open my site then counting of member
will increase.we want count total visit day by day if any one open my site ...
please provide some source code of help me


thanks
samjayander thiagarajan replied to myzonal.com myzonal.com on 16-Apr-10 06:06 AM
Hi,

You can use the session_start and session_end events in the global.asax file to count the number of users.

Here is how you can do that:
void Session_Start(object sender, EventArgs e)
{
    Application.Lock();
    Application["ActiveUsers"] = (int)Application["ActiveUsers"] + 1;
    Application.UnLock();
}
 
void Session_End(object sender, EventArgs e)
{
    Application.Lock();
    Application["ActiveUsers"] = (int)Application["ActiveUsers"] - 1;
    Application.UnLock();
}


Regards,
Sam
Super Man replied to myzonal.com myzonal.com on 16-Apr-10 08:35 AM

there are some website that provides you log of currently login users, today total visit, last day visit.

from which country users are online,

just go through the google.

you have to just add script in your site.thats it

Goniey N (Mr. G) replied to myzonal.com myzonal.com on 16-Apr-10 08:59 AM
For That You Can Take One Table For Storing The Data of Visitors.


When User Will Open your Main Page At That Time On The Page Load Event Retrieve The Last Visitor Number From The Table & Store It In Temporary Variable & The Increment It By One And Then Again Incremented Visitor Number In to Your Table.


That's Way You Can Solve your Problem..


//I Hope This Will Clear You & It Will Work 100%.....