Click here to Skip to main content
Click here to Skip to main content

Application Offline

, 11 Oct 2013
Rate this:
Please Sign up or sign in to vote.
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

Editorial Note

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

ASP.NET Community

United States United States
The ASP.NET Wiki was started by Scott Hanselman in February of 2008. The idea is that folks spend a lot of time trolling the blogs, googlinglive-searching for answers to common "How To" questions. There's piles of fantastic community-created and MSFT-created content out there, but if it's not found by a search engine and the right combination of keywords, it's often lost.
 
The ASP.NET Wiki articles moved to CodeProject in October 2013 and will live on, loved, protected and updated by the community.
Group type: Collaborative Group

247 members


Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 11 Oct 2013
Article Copyright 2013 by ASP.NET Community
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid