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.


  • Just posted a bug to Microsoft Connect

    Please be sure to Validate the problem and post a comment or two on the bug.

    By Blogger bfizzle, at 10:11 PM  

  • does this also disable the app pool the application(s) are in? like say for example I have 3 virtual directories and I place the .htm file in ONE of those applications. Will that bring down ALL THREE applications if all of them share the same app pool?

    By Blogger hotroddiameter, at 11:24 PM  

  • we offer wow power leveling and wow gold wow gold

    By Anonymous Anonymous, at 7:16 AM  

  • Make sure you don't delete default.aspx while you have app_offline.htm - you will get "Directory listing denied" if you do (assuming you don't allow directory listings).

    By Blogger RoscoHead, at 3:06 AM  

  • When I had started learning, I used to remove the default and start getting the error of app_offline. :D
    asp dot net programming

    By Blogger almeda, at 7:59 AM  

  • you won't actualize much. Head off to rec center, pull certain right here weighs, do some cycling and whatnot. -all things considered

    By Blogger ADmin, at 9:14 PM  

  • The article is worth reading, I like it very much. I will share your new articles with other people. Thanks so much for your article.
    Web developer

    By Blogger InnomaxMediaLLP, at 12:24 PM  

  • I recently came across your blog and have been reading along. I thought I would leave link my first comment. I don’t know what to say except that I have enjoyed reading. Nice blog:)

    By Blogger Ivan Pylat, at 11:49 AM  

  • Nice article, thanks for sharing such an ins=formative article with us, must say the way you have presented your thoughts is remarkable.


    Unity | Hire Unity Developers

    By Blogger BitWise Ventures Pvt. Ltd., at 12:00 PM  

Post a Comment

<< Home

Created dolly