ASP.NET WebSite Holding Page - App_Offline.htm


Sponsored Links

73058_New Scooba® 230 Floor Washing Robot + Free Shipping!

 

ASP.NET WebSite Holding Page - App_Offline.htm

On this page we'll look at how to make an ASP.NET WebSite Holding Page, we get to use a a file calle - App_Offline.htm.

When you have an ASP.NET Website, there maybe times when you want to update the site. Sometimes this can be a quick task of just copying new files to the website, users may not notice the change provided everything goes well, apart from the web.config tickle which resets the application.

One trick is to set a redirect inside IIS so that all files are redirected to a holding page, you're holding page containing some text such as 'site under maintenance' (which is a popular one), and then when you have finished you switch off the IIS redirect and the site resumes as normal. Well this works but it would take some effort to setup the redirect and switch it off.

App_Offline.htm

Well it turns out ASP.NET introduced a feature which helps us to do this in a much easier way. All we need to do is call our holding page App_Offline.htm. As soon as there is a file in the root directory of the ASP.NET website called App_Offline.htm then ASP.NET stops serving out dynamic pages and responds to requests for .NET pages such as Index.aspx by returning the App_Offline.htm file. The URL of your page still shows the URL you tried to go to, only the page returned is the HTML you created in your holding page called App_Offline.htm. When we have finished making our upgrade or whatever work we're doing on the site, and it's ready to go live again, simply delete or rename the App_Offline.htm file and ASP.NET resumes normal operation and returns pages which are requested.

So just name our holding page App_Offline.htm and whenever we need to take the site down, upload the App_Offline.htm file, do our work and remove the file when the site is ready to go back up. For development and source control purposes, I hold the file in the Visual Studio solution and call it _App_Offline.htm then whenever I need to use the file I just rename it App_Offline.htm.