app_offline site returning "The service is unavailable."

amateur picture amateur · Jun 16, 2013 · Viewed 8.1k times · Source

I am following Scott gu's trick of placing a App_Offline.htm page at the route of my application to bring it offline - http://weblogs.asp.net/scottgu/archive/2006/04/09/442332.aspx

It does not seem to be working on one of my sites though. I place the file in IIS7 of one my sites, and all traffic is redirected to it.

However in the other site, same server etc, I get a page that contains "The service is unavailable.".

Not sure where I am going wrong - any ideas?

Answer

demoncodemonkey picture demoncodemonkey · Sep 17, 2014

I managed to solve it by putting the following code in my web.config:

<configuration>
    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true" />

        <defaultDocument>
            <files>
                <clear />
                <add value="index.html" />
                <add value="app_offline.htm" />
            </files>
        </defaultDocument>

        <httpErrors errorMode="Custom" existingResponse="Replace">
            <clear />
            <error statusCode="503" path="App_Offline.htm" responseMode="File" />
        </httpErrors>
    </system.webServer>
</configuration>

This fix was found by putting together some info from Scott Gu, npiaseck @ IIS Forum and Kurt Schindler.