title: IIS caching "The layout page could not be found at the following path" error
body: <h2>The Problem</h2>
  <p>I have a website running in IIS. If I rename or delete one of the layout page <code>.cshtml</code> files under <code>/Views/</code> the site immediately begins throwing following yellow screen error as expected</p>
  <pre><code>The layout page &quot;_Layout.cshtml&quot; could not be found at the following path: &quot;~/Views/_Layout.cshtml&quot;.
  </code></pre>
  <p><a href="https://i.stack.imgur.com/ErKuq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ErKuq.png" alt="enter image description here" /></a></p>
  <p>What surprises me is that if I recreate or rename the file so it is exactly like it was before, the yellow screen persists. Why is this particular 500 error sticky?</p>
  <p>I currently think that this has something to do with IIS and is specifically related to error handling. The site immediately detects that the layout page file is missing. It does not immediately realize when the file is back in place.</p>
  <p>Thanks!</p>
  <h2>Some interesting clues</h2>
  <ol>
  <li>This happens on all of my sites I've tried this on so far. It isn't related to a specific site</li>
  <li>I tried this on two websites at the same time. On one site I repeatedly and consistently refreshed the page hoping for a success. On the other, I left it alone for several minutes before checking again. The site I leave alone will resolve its problems and find the layout page on disk again. The site I continually make requests to appears to display the error indefinitely.</li>
  </ol>
  <h2>What I've tried</h2>
  <ol>
  <li>I have reproduced the problem on Umbraco websites using Umbraco's default routing as well as regular MVC pages using custom routing. The problem is the same for both.</li>
  <li>I don't have output caching configured in IIS</li>
  <li>When I am reproducing the yellow screen error, I am able to reproduce the error in multiple browsers, so I don't believe it is related to browser caching</li>
  <li>I checked on the <code>httpRuntime</code> in the root web.config and the <code>fcnMode</code> is set to <code>fcnMode=&quot;Single&quot;</code></li>
  <li>I've fiddled around with the web.config <code>customErrors</code> and <code>httpErrors</code>. Nothing I've done here has affected the problem.</li>
  <li>I am able to reproduce the problem on websites where there is no custom code for caching. No CDN. No load balancer.</li>
  </ol>
  <h2>Versions</h2>
  <ul>
  <li>IIS: I have reproduced the problem on Windows Server 2012R2 running IIS 8 and Windows 11 running IIS 10</li>
  <li>CMS: All of the websites I have tested on so far are Umbraco 7 sites. However, I have reproduced the problem on pages that are routed using Umbraco's out of the box routing as well as pages that are just set up using MVC and aren't leveraging Umbraco.</li>
  </ul>