Home > DeveloperSection > Forums > how to count number of visitors for website
Jeet Verma
Jeet Verma

Total Post:110

Points:776
Posted on    October-04-2014 12:28 AM

 ASP.Net ASP.Net  ASP.NET MVC  C# 
Ratings:


 1 Reply(s)
 664  View(s)
Rate this:
how to count number of visitors for website using asp.net in c#


Kamlakar Singh
Kamlakar Singh

Total Post:194

Points:1396
Posted on    October-04-2014 1:02 AM

Here I will explain how to count number of visitors to website in asp.net using c#
here is Global.asax file

void Application_Start(object sender, EventArgs e)

{

     Application["NoOfVisitors"] = 0;

}

void Session_Start(object sender, EventArgs e)

{

    Application.Lock();

    Application["NoOfVisitors"] = (int)Application["NoOfVisitors"] + 1;

    Application.UnLock();

}


now aspx page

<table>

            <tr>

                <td>

                    <b>No of Visits:</b>

                </td>

                <td>

                    <asp:Label ID="lblCount" runat="server" ForeColor="Red" />

                </td>

            </tr>

        </table>

now aspx.cs page

lblCount.Text = Application["NoOfVisitors"].ToString();


Don't want to miss updates? Please click the below button!

Follow MindStick