Who should read this article
This article is for all IT professionals involved in the complete life cycle of the project, especially for professionals involved in the deployment stage of SDLC.
Intro
In today's world, the customer is the heart of any organization and nobody is allowed to stop the application, even for a second without notifying the user. There are situations where we need to upgrade the production code with a new release and want to display a message to the user, like “site is under maintenance”. The best way to do this is using an app_offline.htm. ASP.Net 2.0+ provided a fantastic functionality that brings the site down and redirects the user automatically to the message page “site is under maintenance".
How it works
The ASP.Net runtime checks the root of the application on the server for an “app_offline.htm” file and if it exists then it stops processing the new requests for the application and redirects the user to the “app_offline.htm” file to notify the user about the change.
To do this, you need to create a temp file, name it “app_offline” with “.htm” extension, load it into the root directory of the application, unload the content of the application from the server and remove the “app_offline.htm” file after loading the application back to the server. Until the time you are loading new content of the application then the user will be redirected to the app_offline.htm file. Once you remove the file, IIS will load the application again and start processing the request to the application as normal.
Customizing the app_offline.htm file
You can place any valid HTML content within the file that you want to display to the user.
Note: There is no upper limit on the size of the file but you need to ensure that you provide at least 512 bytes in the file so that all browsers can process it. If you don't want to display any content, you can place some dummy content and comment it to by the browser's limit restriction.
When to use app_offline.htm file
You can use this file as a feature in the following scenarios:
- You want to replace large content of the application and you don't want new requests for the application in the middle of the content upload.
- Help you to unlock the application files without resetting the ISS.
- Many automatic publishing tools or options also use this file.
The Publish feature of Visual Studio uses this file
Yes, the publish feature of Visual Studio can also upload this file before unloading your application.
Also, you can customize the file used by publish and to do that, you need to find the path of the file on your disk and change it with the customize copy of the file. Normally, the location of the file used in publish differs depending on the version of the Visual Studio you are using.
C:\Users\USERNAME\AppData\Roaming\Microsoft\VisualStudio\[VS 8.0/9.0/10/11/12/13]/app_offline.htm

Anil KumarPosted Mar 3, 2015, 10:57 AM
Muneer MD - No! As per my understanding, the name of the file should be exactly same as "app_offline.htm". Make sure you are not seeing the cached version..
Muneer MDPosted Mar 3, 2015, 8:02 AM
Hey thanks for this one but i don't think it need to be named as app_offline.htm, it even worked for app_1.htm file.. any idea, why ?
Anil KumarPosted Mar 2, 2015, 12:24 PM
Hi Sivaraman - Good question! This is similar to how .net manages transactions in case of crash or how normally deployment is done with shutting the IIS down.
Sivaraman DhamodaranPosted Mar 2, 2015, 8:32 AM
Very Nice Information Anil. I came to know from your article that the presence of app_offline html will not process any new request. As Web admin how do I know about the Transaction which is in middle of something say a credit card transaction? I mean Is there a way to know when it is safe to make large upgrade? (Using app_offline is good to know to take care of new transaction, I am concerned about the existing transaction which is still in processing stage).
Khargesh RajputPosted Mar 2, 2015, 2:28 AM
nice
Rahul Kumar SaxenaPosted Mar 2, 2015, 1:33 AM
Good Show...