Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / web / ASP.NET

Site is Under Maintenance, Please Visit Later: ASP.NET Trick

4.80/5 (3 votes)
8 Jun 2012CPOL2 min read 78.9K  
As a web site owner, we all boast about 24 x 7 uptime. But somewhere down below in our hearts, we know it’s difficult.

24 x 7 Uptime Guaranteed

Image 1

As a web site owner, we all boast about 24 x 7 uptime. But somewhere down below in our hearts, we know it’s difficult. We need to bring down the website for maintenance, fixingdefects, upgrading, etc.

Easy Way…

As an innocent C# ASP.NET developer, you would think how about just stopping IIS web server, do your activity (maintenance, fixing defect, etc.) and then start the IIS again.

Image 2

While this looks to be a but obvious way of solving the problem, it’s not the best way if we consider the end user perspective. The end user would see an ugly screen as shown below leading to more confusion.

Image 3

Rather than end user seeing that kind of absurd screen, how about showing something more better and informative like: “Site is under maintenance and will be live till 3:00 AM”.

Going Offline Graciously:-App_Offline.htm

Also, I would like to highlight here, it’s not about showing the error message but technically we would like to ensure that the following things happen in IIS:-

  • Application domain under which the website is running is brought down.
  • All incoming requests coming to the ASP.NET site need to be stopped.
  • All requests to be routed to the temporary page which is created.
  • After maintenance, the application domain should be loaded and the incoming request should be processed in a normal manner.

Thanks to Microsoft, they always understand our needs. The proper way of approaching this problem is to create a simple “App_offline.htm” file in your application root directory. In this “App_offline.htm”, you can put your user friendly message which the end users can see when the site is under maintenance.

Once done, you can delete the file and your web site app domain is loaded and normal life continues.

Image 4

Image 5

Take a quick look as revision for practical video on "Site is under maintenance"

For further reading do watch the below interview preparation videos and step by step video series.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)