Count Number of Visitors in WebSite using ASP.Net and C#
<p>I want to keep track of the number of visitors to my site. </p>

<p>I tried the following code in the Global.asax class,</p>

<pre><code>&lt;script runat="server"&gt;

  public static int count = 0;
  void Application_Start(object sender, EventArgs e) 
  {
    Application["myCount"] = count;
  }

  void Session_Start(object sender, EventArgs e) 
  {
    count = Convert.ToInt32(Application["myCount"]);
    Application["myCount"] = count + 1;
  }

&lt;/script&gt;
</code></pre>

<p>I am retrieving the value in the aspx page as follows:</p>

<pre><code>protected void Page_Load(object sender, EventArgs e)
{
  int a;
  a = Convert.ToInt32((Application["myCount"]));
  Label4.Text = Convert.ToString(a);
  if (a &lt; 10)
    Label4.Text = "000" + Label4.Text ;
  else if(a&lt;100)
    Label4.Text = "00" + Label4.Text;
  else if(a&lt;1000)
    Label4.Text = "0" + Label4.Text;
}
</code></pre>

<p>The above coding works fine. It generates the Visitors properly but the problem is when I restart my system, the count variable again starts from 0 which logically wrong.</p>

<p>I want the value of count to be incremented by 1 from the last count value.</p>

<p>So can anyone tell me how to accomplish this task?</p>

<p>Please help me out!
Thanks in advance!</p>
