Custom Error Page for Http Error 503

前端 未结 4 871
死守一世寂寞
死守一世寂寞 2020-12-15 07:02

I need to send a Customized Error page for 503 Errors produced by my asp.net website. I have tried to simulate the condition by switching off the application pool (doesn\'t

相关标签:
4条回答
  • 2020-12-15 07:42

    Take a look at HttpContext.Current.Response.TrySkipIisCustomErrors. just a suggestion.

    0 讨论(0)
  • 2020-12-15 07:48

    Ran into the same problems, but I've just managed to get this working for us using a Classic ASP holding page in a .NET application (I'm not sure if it'll work the same for an apsx):

    1. Make sure Classic ASP is enabled in IIS. Worth a read: http://blogs.iis.net/bills/archive/2007/05/21/tips-for-classic-asp-developers-on-iis7.aspx

    2. Create a classic ASP file called Offline.asp and place it in the root of your website with the following contents:

      <%
      
      Response.Status = "503 Service Unavailable"
      Response.CacheControl = "no-cache"
      Response.AddHeader "Pragma", "no-cache"
      Response.Expires = -1
      
      %>
      
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
      <html>
          <head>
              <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
              <meta name="robots" content="noindex,nofollow" />
              <title>Sorry, we're down for essential maintenance</title>
          </head>
          <body><h1>Sorry, we're down for essential maintenance</h1></body>
      </html>
      
    3. Now in IIS7 Manager go the Error Pages administration section, add a Custom Error Page like so:

      Error Pages

      Add Custom Error Page

      Error Pages

    Now whenever IIS receives a 503, it will send the contents of the Offline.asp to the browser, as well as the 503 code (which is important so that Search Engines don't list your error page!)

    Now if you want to take your application offline you can just set up a simple redirect rule to redirect everything to Offline.asp.

    0 讨论(0)
  • 2020-12-15 07:51

    As far as i can see, error pages are kept under %SystemDrive%\inetpub\custerr\<LANGUAGE-TAG>\<HTTP-CODE>.htm

    You can configure custom error pages per website in your iis7 mmc.


    edit

    Apperently there is no way past http.sys in case of 503 - the only choice you get, is to send the default http 503 error message or to terminate the connection on tcp level.

    0 讨论(0)
  • 2020-12-15 07:58

    You cannot customise the default 503 Service Unavailable error message. This is returned typically when the app pool is unavailable for some reason.

    This description of when it occurs states that it comes directly from http.sys and everything on the internet seems to concur that it cannot be changed. I've looked at the http.sys registry settings and theres nothing useful there.

    http://technet.microsoft.com/en-us/library/cc781893(WS.10).aspx

    0 讨论(0)
提交回复
热议问题