title: Application variable got reset after session end
body: <p>I want to insert a visitor counter in my ASP site, so I've used a global.asax file to implement that. The problem is when the session ends the "AllVisitorCount" gets the default value which is set to 0 in my web.Config.</p>
  
  <p>The code is:</p>
  
  <pre><code>void Session_Start(object sender, EventArgs e) {
    // Code that runs when a new session is started
    int allVisitorCount = 0;
    if (Application["AllVisitorCount"] != null)
      allVisitorCount = (int)(Application["AllVisitorCount"]);
    else
      Application.Add("AllVisitorCount", 0);
    allVisitorCount++;
    Application["AllVisitorCount"] = allVisitorCount;
  }
  </code></pre>