Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Application Offline

0.00/5 (No votes)
16 Feb 2008 1  
App_Offline.htm ASP.NET 2.0 introduced the ability to take an application offline simply by adding a file named App_Offline.htm to the

This articles was originally at wiki.asp.net but has now been given a new home on CodeProject. Editing rights for this article has been set at Bronze or above, so please go in and edit and update this article to keep it fresh and relevant.

App_Offline.htm 

ASP.NET 2.0 introduced the ability to take an application offline simply by adding a file named App_Offline.htm to the application root folder.  ASP.NET checks for the presence of this file and, if it exists, stops the app-domain so the application cannot run.  In addition, ASP.NET returns the contents of App_Offline.htm to the requesting browser instead of issuing an IIS error message.  This provides a very neat and user-friendly method of taking an application offline for maintenance or updates.  To return the application to operating status, simply delete the file from the root of the application.

There are two issues to be aware of in using App_Offline.htm.  The first is that it is located in the root of the application, not the root of the web site.  So if your site is at www.sample.com and your application is at www.sample.com/application, you will need to place this file in the /application folder.  Placing the App_Offline.htm at www.sample.com/App_Offline.htm will result in the application still functioning.

The second issue is that Internet Explorer issues friendly errors so as not to alarm the end user, and if the content returned from a request is less than 512 bytes, Internet Explorer will show its own error message instead of the contents of App_Offline.htm.  You could just stuff App_Offline.htm with hidden content in a comment block, but a better choice would be to provide a descriptive page, along with helpful information such as alternate sources for the user, an estimate of when the application will be available or even contact information for users who continue to receive the message.

Visual Studio (all versions) uses the App_Offline.htm file while publishing the application to a web server.  This means that if you have a problem publishing the application and your application stops functioning, there may be an orphaned App_Offline.htm file in your application folder.

Blog Posts

App_Offline.htm and working around the "IE Friendly Errors" feature - Scott Guthrie
ASP.NET 2.0 Features: app_offline.htm - ASP.NET 2.0 Resources
http://aspnet.4guysfromrolla.com/articles/110707-1.aspx - 4guysfromrolla.com

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here