2

I'm implementing google's best practice to get 503 status code when my site is under maintenance.

I do it by checking a value in web.config and then the following code for redirecting the flow to my custom page

Response.Redirect("/maintenance", false);
HttpContext.Current.ApplicationInstance.CompleteRequest();

Inside Page_Load() of the 'maintenance' page I've got

Response.StatusCode = 503;
Response.StatusDescription = "HTTP/1.1 503 Service Temporarily Unavailable";
Response.AddHeader("Retry-After", "Sat, 30 Mar 2016 23:00:00 GMT");

The strange thing happening here is that running the above code shows me the error page of IIS rather than my custom page. Also the same code works fine in my other application.

If I don't assign to Response.StatusCode, it works fine.

I've got an entry in my web.config for a 404 redirect like so

  <httpErrors errorMode="Detailed" existingResponse="Replace" defaultResponseMode="Redirect">
      <remove statusCode="404" subStatusCode="-1" />
      <error statusCode="404" prefixLanguageFilePath="" path="/error-page" responseMode="ExecuteURL" />
  </httpErrors>

This makes sense. But I doubt it as commenting it redirects me to my custom page.

Any help is appreciated.

Parth
  • 568
  • 2
  • 6
  • 23

0 Answers0