Click here to Skip to main content
5,786,882 members and growing! (24,254 online)
Email Password   helpLost your password?
Web Development » ASP.NET » Howto     Intermediate License: The Common Development and Distribution License (CDDL)

How to redirect the user to a "Down for Maintenance" page in ASP.NET

By Sandeep Aparajit

This article will help you understand a superb hidden feature of ASP.NET. Using this feature, you could easily redirect all your website traffic to a "Down for Maintenance" page.
Windows, ASP.NET, SysAdmin, Dev

Posted: 16 Aug 2008
Updated: 16 Aug 2008
Views: 4,293
Bookmarked: 12 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
11 votes for this Article.
Popularity: 3.52 Rating: 3.38 out of 5
3 votes, 27.3%
1
1 vote, 9.1%
2
0 votes, 0.0%
3
1 vote, 9.1%
4
6 votes, 54.5%
5

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

  • Version 1.0 of article released on 16 August 08.
  • Version 1.1 of article released on 19 August 08. In this version, I modified the "512 KB" value to "512 bytes". This was a superb comment from one of the readers. Thanks to all readers!

License

This article, along with any associated source code and files, is licensed under The Common Development and Distribution License (CDDL)

About the Author

Sandeep Aparajit


Sandeep is a senior software developer at TCS, Pune. He has 4+ yrs of IT experience. He is Microsoft Certified Technology Specialist and has been certified for Analyzing Requirements and Defining Microsoft .NET Solution Architectures.
He is an active member of:
1. MSDN Forums
2. CodeProject.com
3. Community-Credit.com
4. Blogspot.com

You can find his contributions at:
http://aparajit.co.in/blogs/sandeep

http://sandeep-aparajit.blogspot.com

Occupation: Software Developer (Senior)
Company: Tata Consultancy Services
Location: India India

Other popular ASP.NET articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 7 of 7 (Total in Forum: 7) (Refresh)FirstPrevNext
GeneralNice TipsmemberAbhijit Jana5:11 20 Aug '08  
GeneralRe: Nice TipsmemberSandeep Aparajit13:22 20 Aug '08  
GeneralAwesomemembermerlin9815:09 19 Aug '08  
GeneralRe: AwesomememberSandeep Aparajit7:41 19 Aug '08  
GeneralNot 512KB, File size is only 512 bytesmemberGazi Md. Saiful Islam19:34 18 Aug '08  
GeneralRe: Not 512KB, File size is only 512 bytesmemberRuchit Surati22:05 18 Aug '08  
GeneralRe: Not 512KB, File size is only 512 bytesmemberSandeep Aparajit5:42 19 Aug '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 16 Aug 2008
Editor: Smitha Vijayan
Copyright 2008 by Sandeep Aparajit
Everything else Copyright © CodeProject, 1999-2009
Web18 | Advertise on the Code Project