ASP.NET 2.0 Resources

Powered by Blogger

ASP.NET 2.0 Features: app_offline.htm

There is a simple way to bring down your ASP.NET 2.0 application. The only thing you have to do is to create simple html file called App_offline.htm and deploy it to your ASP.NET 2.0 web application root directory. The rest is handled by ASP.NET runtime internal routines. But there are also some hidden drawbacks, so keep reading.

Just after you deploy this file, ASP.NET 2.0 runtime stops the application and unloads whole application domain. It stops processing new incomming requests and serves your App_offline.htm file insted. Because whole application domain is unloaded all application files and assemblies are now unlocked and you can make any necessary changes. When you are ready, rename or delete App_offline.htm file and the next incomming request will bring the ASP.NET 2.0 web application back online.

The App_offline.htm file is also used internally by Visual Studio 2005 and Visual Web Developer when deploying web sites to server. If something unusual happend during web site publish, there is a possibility this file will remain on the server and the application will not be functional. So be sure always to check your web application after publishing from Visual Studio 2005 and Visual Web Developer.

But there is one thing you should became aware of when using App_offline.htm file to temporarily shut down your ASP.NET 2.0 web application. When this file is present, all requests are served with this file and returned with status code 404 Not Found. I don't understand why ASP.NET team used this status code, because it clearly is not correct in such situation. The web application pages are only temporarily unavailable, but this status code sais they were not found (that they were deleted)!

Search engine spiders would interpret this status code and remove requested page from their search database. The next thing is Internet Explorer does not show contents of App_offline.htm file in it's default configuration, but a generic friendly message associated with the 404 status code. Fortunately there is a workaround for Internet Explorer friendly message. Internet Explorer first looks at the page size and if it's bigger than 512 bytes 404 status code friendly message is not displayed and user is served with your App_offline.htm content.

So be sure to use this method how to maintain ASP.NET 2.0 application wisely and keep the App_offline.htm deployed for as short time as possible. There is a HTTP status code 503 Service Unavailable meant exactly for such situations when the requested resource is temprorarily unavailable, so let's hope this bad behavior will be changed in the future releases of ASP.NET 2.0 framework.

But enough talking, lets look at some example. I have created this simple App_offline.htm file...

    <title>Application unavailable</title>
    The application is down for maintenance. Please try again in a while.
     Add additional content to make this file bigger than 512 bytes...

Just after i deploy this file to my ASP.NET 2.0 Web Application root directory, this message appears for every application page request.

ASP.NET 2.0 App_offline.htm file request

When i rename or delete this file, the application is brought instantly back online.


Post a Comment

<< Home

Created dolly