how to count number of visitors for website

Total Post:110

Points:776
 1288  View(s)
Ratings:
Rate this:
how to count number of visitors for website using asp.net in c#
  1. 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();

      Modified On Apr-05-2018 06:28:38 AM

Answer