title: Does changing any sub-directory or file in an ASP.NET application recycles the app pool
body: <p>I thought I knew ASP.NET well, until a couple of hours ago. I am aware an IIS can recycle an app domain due to a variety of reasons including changes to web.config/bin/App_GlobalResources etc. file/directories, or otherwise on schedule or on specific events (like reaching a specific memory threshhold).</p>
  
  <p>I was very sure my code was NOT hitting any of these conditions. Basically a regular http request would trigger a small task in a background thread (ThreadPool.QueueUserWorkItem) that woould lead to writing of a pdf file inside a sub-directory of my ASP.NET app.</p>
  
  <p>This sub-directory had nothing that would qualify it for causing a app recycle. It was something like:</p>
  
  <p>My Site\CompanyName\Mailer\UploadFiles</p>
  
  <p>Please don't suggest reasons like configuration or bin directory change, the code is changing nothing in ASP.NET folders. Its writing to a pdf file inside a non-ASP.NET directory.</p>
  
  <p>I used the Application_End event to figure out the reason of recycle (using reflection as suggested here: <a href="http://weblogs.asp.net/scottgu/archive/2005/12/14/433194.aspx" rel="nofollow">http://weblogs.asp.net/scottgu/archive/2005/12/14/433194.aspx</a>) and got this:</p>
  
  <pre><code>_shutDownMessage=Directory rename change notification for 'd:\Projects\MyProject\trunk\dev'.
  dev dir change or directory rename
  HostingEnvironment initiated shutdown
  HostingEnvironment caused shutdown
  Directory rename change notification for 'd:\Projects\MyProject\trunk\dev'.
  dev dir change or directory rename
  </code></pre>
  
  <p>I am practically stumped. I am very sure I have written code on other projects which writes under the app's sub-direcories without causing app recycles. But not in this case.</p>
  
  <p>Am I missing something? Is it expected for IIS to recycle the app domain trying to write to any sub-directory of the app from the ASP.NET app itself?</p>