Tuesday, March 17, 2009

ASP.Net – Taking a website offline

In one word “app_offline.htm”.

image Just drop a file named “app_offline.htm” into the root of your web-app. When ASP.NET finds it, it will shut-down the app-domain for the application. In addition it will not restart it for requests and it will respond to clients with the contents of the app_offline.htm file.

Delete this file after you complete updating the website and your app will auto-magically come back online.

Notes on using “app_offline.htm”:

  • ASP.NET will not return an “app_offline.htm” file if it exceeds 1 MB in size.
  • If the “app_offline.htm” file is too small (less than 512 bytes), Internet Explorer will display its "Friendly Http Errors", rather than the content in “app_offline.htm”.
  • The nice thing about app_offline.htm is that it will only stop processing new requests to your site, but it will continue processing requests from those that are already connected to your site. So if you are providing transaction processing - this feature can be extremely handy - just be sure to leave the app alone for a while before updating the files, least you trigger a restart while a user was in the middle of a transaction.
Other keywords for this post: shutdown asp.net, turn off asp.net, stop processing asp.net website

No comments: