asp.netasp.net-mvciisiis-7app-offline.htm

Change http status 503 to 200 when serving app_offline.htm for specific URL


The app_offline.htm file that ASP.NET serves returns the http status 503. This is the correct behavior for most situations. However, in the scenario where a specific URL is requested (e.g. https://www.mywebsite.com/monitor), I'd like to change the returned http status to 200, while still returning http status 503 in all other situations. Is this possible?

The reason why I want to do this is whenever we do scheduled maintenance on our website, we use the app_offline.htm file, but we don't want our uptime monitoring service (Pingdom.com) to report downtime during our scheduled maintenance.

I assume this would have to be at the IIS level because the app_offline.htm gets served very early on in the request processing cycle.


Solution

  • Note that App_Offline is only there to take the ASP.NET part down, it has nothing to do with the IIS site. All non-ASP.NET request -like .htm- will go through the normal IIS pipeline.

    That being said, a HTTP 503 is an unavailable service error. The App_Offline.htm take the site partially offline, it is normal and correct that all ASP.NET request get a 503 response when the site is offline.

    Bypass this with a HttpModule or whatever code in the ASP.NET pipeline is not a valid solution.

    Since you'are already creating/copying the App_Offline.htm in your IIS root during maintenance, I'll suggest to add maintenance.htm as a default document for your /monitor folder or your IIS site and create/copy a maintenance.htm file in it during maintenance : then the default page will be reach whatever the ASP.NET site is offline or not.

    If your probe is calling the http://servername/monitor/ uri without any page specified, it will work.

    You just have to delete it -like you delete your App_Offline- after the maintenance.