ASP.NET 2.0: Strange 404 Errors and the "App_Offline.htm" file

If you get strange HTTP 404 errors in your ASP.NET 2.0 application, always check for a zero-length "magic file" called app_offline.htm and delete it. If this file is present in your web site, then the entire application will be considered offline by the ASP.NET runtime. There is actually a button that says "Take application offline" which creates this file, but unfortunately the "magic file" can also "magically appear", so you can spend quite some time chasing bugs that aren't there. Post-beta 2 builds are expected to provide a proper explanation.

The reason it can appear by itself is that it's used to "take the application offline" when copying a web site. If this operation crashes somewhere in the middle for some reason, the file doesn't get deleted. For ADO.NET and Databases, if ASP.NET has open connections, you can shut down the application domain by adding a file named "app_offline.htm" to the Web application root directory. This has the effect of shutting down the application domain (not the process) and redirecting all requests to the application to this file (returning a 404 response code).

To allow the application to restart, remove this file. Note that simply closing connections in your page code will not release the file lock, because by default the ADO.NET connection pool retains the active connections.