Silverlight 3.0 app_offline.htm
This is one of the interesting thing noticed when I build a Silverlight 3 application frequently. Part of the build process appears to involve generating an app_offline.htm file which eventually ends up being added to the Recycle Bin.
As per ASP.Net theory, this file at first used to shutdown the web site/application hosting the Silverlight application to release or unlock resources needed in the build of the assemblies or generation of the .xap file. Exactly at the time of the build start process, a file of this name is getting created and moved to Recycle Bin.
App_offline.htm file functionality is there from ASP.NET 2.0. If you place a file named app_offline.htm into the root of an ASP.NET 2.0 application, the application will shutdown and any page request for the application will return this file instead. This feature makes it extremely easy to take down an application while a large update is being made. As soon as you remove the file any page requests to the application will continue as normal. This works with ASP.NET 2.0 and later. This basically will shut-down the application, unload the application domain from the server, and stop processing any new incoming requests for that application.
ASP.NET will also then respond to all requests for dynamic pages in the application by sending back the content of the App_offline.htm file Once you remove the App_offline.htm file, the next request into the application will cause ASP.NET to load the application and app-domain again, and it will be back to normal. One type of error message we see if this App_offline.htm file is available in the root directly is as ""This application is currently offline. To enable the application, remove the app_offline.htm file from the application root directory". To make the system working is to browse to the directly and remove the file manually.
ASP.NET checks for the presence of this file and, if it exists, stops the app-domain so the application cannot run. In addition, ASP.NET returns the contents of App_Offline.htm to the requesting browser instead of issuing an IIS error message. This provides a very neat and user-friendly method of taking an application offline for maintenance or updates. To return the application to operating status, simply delete the file from the root of the application. There are two issues to be aware of in using App_Offline.htm. The first is that it is located in the root of the application, not the root of the web site. So if your site is at www.mysite.com and your application is at www.mysite.com/application, you will need to place this file in the /application folder. Placing the App_Offline.htm at www.mysite.com/App_Offline.htm will result in the application still functioning.
The second issue is that Internet Explorer issues friendly errors so as not to alarm the end user, and if the content returned from a request is less than 512 bytes, Internet Explorer will show its own error message instead of the contents of App_Offline.htm. You could just stuff App_Offline.htm with hidden content in a comment block, but a better choice would be to provide a descriptive page, along with helpful information such as alternate sources for the user, an estimate of when the application will be available or even contact information for users who continue to receive the message. Visual Studio (all versions) uses the App_Offline.htm file while publishing the application to a web server. This means that if you have a problem publishing the application and your application stops functioning, there may be an orphaned App_Offline.htm file in your application folder.
Another issue is as here, if do a frequent web publish. Publishing fails as this message : Unable to add 'app_offline.htm' to the Web site. The file 'app_offline.htm' already exists in this Web site.Error: The operation could not be completed. Unspecified error. Here again we need to manually delete this file to proceed.
Reference Articles
