Search
Monday, November 19, 2018 ..:: Home ::.. Register  Login
   Calendar  
     
  
   Search  
     
  
   Blogroll  
     
  
   Disclosure  
All blog entries are the opinions of the author and do not necessarily reflect the opinions of their employer. All the code presented is for explanation and demonstration purposes only. Any damages incurred to your site and/or data are not the responsibility of the author. Every effort is taken to ensure the code properly compiles, however sometimes there are some hiccups and you might be required to do your own debugging.
     
  
   TechTidBits (Blog)  

Ever want to take your IIS website offline quickly to do something? Check out app_offline.htm

Apr 7

Written by:
Tuesday, April 07, 2009 10:34 PM  RssIcon

Have you ever wanted to take down your website quickly but weren't quite sure how?  Ever been hit with a bad virus/hacker and want to immediately shut things down?  Have you ever wanted to do an upgrade to your website but would like to spare your users bad error messages or confusing them by seeing wonky screens of half upgrades pages?  Read on about a cool file IIS uses if it's present to take a site offline.

IIS has a cool secret up it's sleeve to quickly take a website offline.  If IIS sees a file named app_offline.htm in a website's root directory, it doesn't matter what page/file you asked for, it's going to serve up the app_offline.htm file!  Amazing!  That's the fastest way to take your website offline for maintenance, upgrades or just to have fun. :>>>>

Website offline page as seen in IE

Above is a sample app_offline.htm file I created to test this out.  Below is the sample file I used for above.

<html> 
<HEAD><title>PCHenry.com Offline</title>
</head>
<body>
	<H1>www.PCHenry.com is temporarily offline.</H1> 
	<BR> 
	<H3>Please come back again soon as we're working on the issue now.</H3>
</body>
</html>


Please note, you cannot use the "html" extension, it has to be "htm" (notice the absence of the trailing "L"?).  Well, you COULD name it that, but IIS isn' programmed to look for that filename and serve up.

There is one hiccup with this app_offline.htm scenario.  If you are creative, you could easily create an admin page to rename an app_offline.htm.backup so IIS sees it and take the website offline.  But then what?  Can you see where I'm going with this?  If you create a page to take the website offline remotely, how are you going to bring it back online?  You effictively have no more programming aspects to that website. 

The solution?  If you plan on doing this, you should either accept having to truck back into the office to delete/rename the app_offline.htm file OR create a sister website to delete/rename the app_offline.htm for you.  If you went so far as to create the admin page to take offline, I'm guessing creating the sister site isn't going to be too much work for you.

Now that you've had some fun with IIS, go grab a coffee and get coding! :>

 

Resources:

Scott Guthrie: App_Offline.htm

15 Seconds: Taking an ASP.NET 2.0 Application Offline, John Peterson

Tags:
Categories:
Location: Blogs Parent Separator TechTidBits

1 comment(s) so far...


Re: Ever want to take your IIS website offline quickly to do something? Check out app_offline.htm

Interesting Finds, Jason Haley, http://jasonhaley.com/blog/post/2009/04/08/Interesting-Finds-April-8-2009.aspx

Very cool! I love it! :>

By phenry on   Wednesday, April 08, 2009 10:22 AM

Your name:
Gravatar Preview
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Add Comment   Cancel 
     
  
Copyright 1999-2012 by PCHenry.com   Terms Of Use  Privacy Statement