title: How to Determine ASP.NET Application Domain Lifetime
body: <p>We have an application gathering counter statistics and we would like the values to reset after executing the <code>iisreset</code> command and that's all. </p>
  
  <p>Microsoft says <code>Application_Start</code> is:</p>
  
  <blockquote>
    <p>Called when the first resource (such
    as a page) in an ASP.NET application
    is requested. The Application_Start 
    method <strong>is called only one time during
    the life cycle of an application</strong>. You
    can use this method to perform startup
    tasks such as loading data into the
    cache and initializing static values.</p>
  </blockquote>
  
  <p>This is how we're currently doing it:</p>
  
  <pre><code>protected void Application_Start(object sender, EventArgs e)
  {
      _counters.Get&lt;AutoCounter&gt;("TAS:RequestCount").Reset();
      _counters.Get&lt;AutoCounter&gt;("TAS:RequestTime").Reset();
      _counters.Get&lt;AutoCounter&gt;("TAS:TimeBetweenErrors").Reset();
      _counters.Get&lt;AutoCounter&gt;("TAS:ErrorCount").Reset();
  }
  </code></pre>
  
  <p>However, these are resetting at unexpected intervals. What determines when the application domain's life-cycle ends and this method is called on the next request?</p>