I have a website running in IIS. If I rename or delete one of the layout page .cshtml
files under /Views/
the site immediately begins throwing following yellow screen error as expected
The layout page "_Layout.cshtml" could not be found at the following path: "~/Views/_Layout.cshtml".
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?
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.
Thanks!
httpRuntime
in the root web.config and the fcnMode
is set to fcnMode="Single"
customErrors
and httpErrors
. Nothing I've done here has affected the problem.It appears to be part of the behavior of FcnMode="Single"
. See https://learn.microsoft.com/en-us/dotnet/api/system.web.configuration.fcnmode?view=netframework-4.8. It isn't an issue with caching. It is a problem with the way that the site's file change notifications (FCN) are configured.
The sticky 500 behavior on renaming files happens when I use FcnMode="Single"
but not when I use FcnMode="Default"
.
FcnMode="Single"
will result in only a single object to monitor file changes. This single object is responsible for monitoring changes to files in the main directory and sub directories.
FcnMode="Default"
will result in a separate object to monitor file changes for each directory.
Umbraco sites, by default, use FcnMode="Single"
. This makes sense because Umbraco sites cache under very deeply nested directories in /App_Data/
. This can result in so many of these monitors that it can affect the performance of the site. There is a great explanation of FcnMode and why it matters for Umbraco here: https://shazwazza.com/post/all-about-aspnet-file-change-notification-fcn/
Unfortunately, it appears that the single file monitor can miss renames of files in some cases.