I was reading through my backlog of feeds ( which has gotten huge ) and ran across this little gem. It is a very cool feature of ASP.NET 2.0 that I had missed. In fact, I can't seem to find any reference to it in two of my ASP.NET 2.0 books. This feature is quite simple to use and extremely useful.
There are times when you may want to take your ASP.NET application offline. You may be doing a major upgrade to the code or need access to resources that may be tied up. You certainly don't want your customers seeing a "Page not Found" or some some other type of error due to upgrading code or maintenance of some sort. You want them to get a page with information on what is happening and maybe when to check back.
ASP.NET 2.0 has a special filename called app_offline.htm. This file is a standard html document and when present in the application root directory, will be shown in place of all other page requests. You can have this file on standby and when upgrade time rolls around you can simply drag the file into the application directory to be updated, update your files, and once finished you would delete the file from the directory.
You should also note that Internet Explorer has a habit of showing "Friendly Http Errors" when the content is less than 512 bytes long. To work around this, you should either insure your page greater than 512 bytes or add some comments in the mark up to make up the difference.
The following is an example of a app_offline.htm file. The content is not limited, so you can pretty much make it say whatever you want.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Application Offline</title>
</head>
<style>
div { background-color:#ffffcc;
padding-top:10px;
padding-bottom:10px;
padding-left:10px;
padding-right:10px;
border-style:solid;
border-color:Black;
border-width:1px;
}
</style>
<body>
<div>
This application is currently offline and under going maintenance. Please check back later.
</div>
</html>
This is a very simple example file. You can make yours nicely formatted with whatever graphics you require.