title: Detecting when an ASP.NET application recycles
body: <p>I'm trying to detect when an ASP.NET application is recycling due to either the web.config file being modified or the IIS application pool being manually recycled. </p>
  
  <p>Initially I thought ASP.NET's Application_End method would work, and tried the following:</p>
  
  <pre><code>protected void Application_End(object sender, EventArgs e)
  {
      File.AppendAllText("log.txt", DateTime.Now + "\n");
  }
  </code></pre>
  
  <p>The file was created the first time the web.config file was changed, but subsequent changes didn't fire the event. Similarly, when testing in IIS, the first manual application pool recycle created the file but later ones didn't - it's as if the Application_End event only ever fires once.</p>
  
  <p>How would I detect each time the pool/app recycles?</p>