Show number of visitors in application

08 Mar 2018 vikram singh
9 Comments 4203 Views

Sometimes we need to display how to show online visitors in website. Here I will be explaining how we can count number of visitors of a particular website in


To achieve this, simply we need to add Global.asax in our application.

Steps for this would be as follow-

1- Open visual studio

2- Create New website

3- Right click on solution explorer bar

4- then select add new item

5- select global application class file from given options

6- click ok and you are done.


void Application_Start(object sender, EventArgs e)
// Code that runs on application startup
Application["NoOfVisitor"] = 0;

void Session_Start(object sender, EventArgs e)
// Code that runs when a new session is started
Application["NoOfVisitors"] = (int)Application["NoOfVisitors"] + 1;


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
    <title>Freshcode Hub</title>
    <form id="form1" runat="server">
                    <b>No of Visits:</b>
                    <asp:Label ID="lblCountVisits" runat="server" ForeColor="Red" />

CS Page

protected void Page_Load(object sender, EventArgs e)
        lblCountVisits.Text = Application["NoOfVisitors"].ToString();


vikram singh

I am developer with 3+ years exp. in, jquery, javascript,SQL area knowledege.


No coments found to display!

Leave a Comment