Thursday, June 11, 2009

App Offline File

A colleague pointed out this extremely useful tip for a quick and easy way to provide a friendly message to users when a SharePoint site is being upgraded or changes are  occurring behind the scenes.  This applies not just to SharePoint 2007 sites, but any .NET 2.0 application.

By simply placing an HTML file named app_offline.htm in the root of your web application (not necessarily the root of your web server), your users will get your custom HTML message instead of a nasty ASP.NET error message.   One caveat to this is to be sure that the file is at least 512 bytes in size.  If you don’t have enough text in your custom app_offline.htm page, just add a series of hidden comments. 

The beauty of this is that you can have this file ready and waiting, and it only takes a few seconds to copy it to the right folder before performing any maintenance. 

If you have a lot of SharePoint web applications and you were not consistent in your naming of their virtual directories (like I did), right click on your SharePoint web site in IIS 7, and select Explore.  This will open the root of your web application on the file system.  Drag and drop your app_offline.htm file to this folder.  When your maintenance is complete, drag this file out the folder.

A great resource and a simple example of this can be found at ScottGu's blog site.