سؤال

I've just set up a "maintenance" mode for my Appharbor web application. By setting a config variable, the site will redirect users to a custom "down for maintenance" page. I want this page to be returned with an HTTP 503 status, so the site won't be indexed while it's down. I'm setting the response code in the action like so:

public ActionResult Maintenance()
{
    Response.StatusCode = 503;
    return View();
}

This all works the way I want on my local server. I get my custom view with the 503 status code. However once I deploy to AppHarbor, I'm getting a plain nginx 503 error page. Seems nginx may be intercepting the response and returning its own error. Any ideas on how to get a custom body to show up along with the 503 status? Here's the raw response I'm seeing:

HTTP/1.1 503 Service Unavailable
Server: nginx
Date: Fri, 07 Jun 2013 19:26:09 GMT
Content-Type: text/html
Content-Length: 27
Connection: keep-alive
Cache-Control: private

The service is unavailable.
هل كانت مفيدة؟

المحلول

The message The service is unavailable. is actually IIS's default HTTP 503 message. The problem is that IIS (not nginx) intercepts and rewrites the response by default.

You can configure this behavior by using the httpErrors element in your web.config like so:

<system.webServer>
    <httpErrors existingResponse="PassThrough"></httpErrors>
</system.webServer>

Note that configuring this may have security implications for your application. You can read more about configuring httpErrors in this article

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top