Click here to Skip to main content
Email Password   helpLost your password?

Introduction

Usually, there arises a scenario when we upgrade our production site to a new release, we want the users to be redirected to the “Down for Maintenance” page. This article will help you understand the easiest technique to redirect all your website traffic to a standard "Down for Maintenance" HTML page.

How to redirect a user to a "Down for Maintenance" page?

The best way to implement this is using the app_offline.htm file. ASP.NET 2.0 has provided a fantastic functionality using which the users will automatically be redirected to the “Down for Maintenance” page. Just add an HTML file named “app_offline.htm” to the root directory of your website. Adding this file will clear the server cache. When ASP.NET sees the app_offline.htm file, it will shut-down the app-domain for the application (and not restart it for requests), and instead send back the contents of the app_offline.htm file in response to all new dynamic requests for the application.

Please take a note that the size of the file should be more that 512 bytes to be displayed. If the size of the file is less that 512 bytes, then IE browser settings need to be changed manually. The "Show Friendly HTTP Errors" check box from the Tools->Internet Options->Advanced tab within IE settings need to be unchecked. If this check-box is not unchecked and the app_offline.htm file size is less that 512 bytes, then the standard IE “Page cannot be displayed” message will be shown.

To start the website again, just remove this file from the root folder of your website. This will trigger the ASP.NET engine to cache all the page contents and display the pages. This has really made life simple :)

Points of interest

Sharing my experience: I have faced a similar situation in one of my projects, where we actually wrote an event handler in the Global.asax page to redirect the user to a standard HTML page, or used the redirect settings of IIS. But then, I came accros this awesome functionality provided by ASP.NET 2.0, and thought of sharing this golden concept with you all :)

Hope this helps! Your comments are always welcome!

History

You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
GeneralEasy to use but has some flaws
aphazel
2:22 16 Nov '09  
This method was created for Microsoft's internal use. Looks pretty kool but it has some flaws like 404 response instead of 503 and MS is not going to change it[^].
GeneralNice Tips
Abhijit Jana
5:11 20 Aug '08  
Full Credit from me


GeneralRe: Nice Tips
Sandeep Aparajit
13:22 20 Aug '08  
Thanks!

------------------------------
Sandeep Aparajit
Mark usefull posts as Helpful/Answers.
http://sandeep-aparajit.blogspot.com

GeneralAwesome
merlin981
5:09 19 Aug '08  
I love these little undocumented tips! Thank you. 5 from me



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
LINQ Exchange - Learn about LINQ and Lambda Expressions
Joke of the Day and Random Jokes - ReallyFunnyQuickJokes.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

GeneralRe: Awesome
Sandeep Aparajit
7:41 19 Aug '08  
Thanks merlin981!

------------------------------
Sandeep Aparajit
Mark usefull posts as Helpful/Answers.
http://sandeep-aparajit.blogspot.com

GeneralNot 512KB, File size is only 512 bytes
Gazi Md. Saiful Islam
19:34 18 Aug '08  
As per I know "app_offline.htm" file size should be more than only 512 bytes Not 512 KB as you mentioned in this article.

Thanks for your nice article.

--
Gazi Md. Saiful Islam

GeneralRe: Not 512KB, File size is only 512 bytes
Ruchit Surati
22:05 18 Aug '08  
Yes,

Its absolutely true. The File Size MUST be atleast 512 BYTES.


Thanks.

Ruchit S.
http://ruchitsurati.net

******************************************

GeneralRe: Not 512KB, File size is only 512 bytes
Sandeep Aparajit
5:42 19 Aug '08  
Agreed !!!
I have modified the article to have the value of file size as "512 bytes" instead of "512 KB". Thanks for your comments!

------------------------------
Sandeep Aparajit
Mark usefull posts as Helpful/Answers.
http://sandeep-aparajit.blogspot.com


Last Updated 17 Aug 2008 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2010