title: When does an ASP.NET Website project recompile?
body: <p>As <a href="https://stackoverflow.com/users/21239/mauricio-scheffer">Maurico</a> and <a href="https://stackoverflow.com/users/241462/codeka">codeka</a> first stated, don't use the default <a href="http://msdn.microsoft.com/en-us/library/ms178586(v=VS.80).aspx" rel="nofollow noreferrer">InProc sessions</a> if you don't want your sessions to be affected by website recompiles and application recycles. </p>
  
  <p>A list of what causes whole website recompile: </p>
  
  <ol>
  <li><p>By default, when any change is made to a <em>top-level file</em> in a Web site, the whole site is recompiled. Top-level files include the <strong>global.asax</strong> file and all files in the <strong>bin/</strong> and <strong>App_Code/</strong> folders.</p></li>
  <li><p>modifying <a href="http://msdn.microsoft.com/en-us/library/aa719558(VS.71).aspx" rel="nofollow noreferrer">web.config</a> </p></li>
  <li><p>a configuration include file change, if the <a href="http://msdn.microsoft.com/en-us/library/system.configuration.sectioninformation.restartonexternalchanges.aspx" rel="nofollow noreferrer">SectionInformation.RestartOnExternalChanges property</a> is true</p>
  
  <p>&lt;section 
      name="MyAppSettings" 
      type="System.Configuration.AppSettingsSection, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 
      <strong>restartOnExternalChanges</strong>="<strong>true</strong>" 
      requirePermission="false" /&gt;</p></li>
  </ol>
  
  <p>Notes:</p>
  
  <ul>
  <li>If you want to be able to change top-level files without causing the whole site to be recompiled, you can set the <a href="http://msdn.microsoft.com/en-us/library/system.web.configuration.compilationsection.optimizecompilations.aspx" rel="nofollow noreferrer">optimizeCompilations attribute</a> of the compilation element in the Web.config file to true</li>
  </ul>
  
  <p>References:</p>
  
  <ul>
  <li><a href="http://msdn.microsoft.com/en-us/library/ms366723.aspx" rel="nofollow noreferrer">Understanding ASP.NET Dynamic Compilation</a></li>
  </ul>
  
  <hr>
  
  <p>Where's the info that tells the kinds of changes and files which cause a website project (not web application project) to recompile itself?</p>
  
  <p>The reason I'm asking is because we don't want users to lose their sessions. Therefore we want to update the live website with recompilable changes only in the very wee hours of the morning, but would prefer to make changes during the day to expedite them. We do promote to a staging server first and watch it there, but a definitive list would be nice in advance.</p>