ASP.net has a feature that makes an application in the offline mode. In offline mode, ASP.net does not serve any request made to the application. Instead it returned an error message, which can be customized, to the user. This feature uses a file called app_offline.htm.
When ASP.Net found a file names app_offlinne.htm in the root of a web application directory, it shut-down the application, unload the application domain from the server, and stop processing any new incoming requests for that application. ASP.NET also then respond to all requests for dynamic pages in the application by sending back the content of the app_offline.htm file. The default content is an error message
'The application is currently offline. Remove app_offline.htm file from applications root directory.'
Visual Studio 2005 And app_offline.htm
SQL Server 2005 express edition does not support multiple processes. Only single process can access database at a time. So when a database is accessed through visual studio, ASP.net runtime cannot access the database. This will result into the internal server error. To prevent this, VS 2005 places app_offline.htm file in the application's root directory. The file contain above message. This causes ASP.net to put the application in offline mode. Please note the accessing database means opening any component of the database (I.e. table, view, stored procedure etc.) into the design window. When design window is closed, VS 2005 removes app_offline.htm file making the application in onliner mode again.
Using app_offline.htm As A Feature
You may use app_offline.htm feature to put your application in offline mope for any purpose. This provides a convenient way to take down your application while you are making big changes or copying in lots of new page functionality (and you want to avoid the annoying problem of people hitting and activating your site in the middle of a content update). It can also be a useful way to immediately unlock and unload a SQL Express or Access database whose .mdf or .mdb data files are residing in the /app_data directory.
You should keep an eye on a feature of IE6 called "Show Friendly Http Errors". This can be configured in the Tools->Internet Options->Advanced tab within IE, and is on by default with IE6. When this is on, and a server returns a non HTTP-200 status code with less than 512 bytes of content, IE will not show the returned HTML and instead substitutes its own generic status code message.
So if you use the app_offline.htm feature, you should make sure you have at least 512 bytes of content within it to make sure that your HTML (instead of IE's friendly status message) shows up to your users. If you don't want to have a lot of text show-up on the page, one trick you can use is to just add an html client-side comment with some bogus content to push it over 512 bytes.
Once you remove the app_offline.htm file, the next request to the application will cause ASP.NET to load the application and app-domain again, and life will continue along as normal.
- Andy Gray wrote an interesting story on how his application stops working and starts giving error 404 when he killed visual studio process.
- Phill Scott writes his experience about suddenly getting error 404 and finding the app_offline.htm file culprit.
- Chris Ullman , author of Beginning ASP.NET 2.0 also had similar experience.
- Microsoft's ScottGu's Weblog.