HOW TO COUNT NUMBER OF VISITORS FOR WEBSITE

Jeet Verma

Total Post:110

Points:776
Posted by  Jeet Verma
 1025  View(s)
Ratings:
Rate this:
how to count number of visitors for website using asp.net in c#
  1. Kamlakar Singh

    Post:194

    Points:1396
    Re: how to count number of visitors for website

    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();

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!