I'm trying to get custom error pages work to no avail. This configuration is adapted from samples I've found online. Using IIS 7.0 hosted by GoDaddy.

The below code gives me "The page cannot be displayed because an internal server error has occurred." instead of redirecting.

<configuration>  
    <system.webServer>

        <httpErrors>
        <remove statusCode="401" subStatusCode="-1" />
        <remove statusCode="403" subStatusCode="-1" />      
        <remove statusCode="404" subStatusCode="-1" />                
        <remove statusCode="500" subStatusCode="-1" />
        <error statusCode="401" path="http://www.mywebsite.com/error.html" responseMode="Redirect" />
        <error statusCode="403" path="http://www.mywebsite.com/error.html" responseMode="Redirect" />
        <error statusCode="404" path="http://www.mywebsite.com/error.html" responseMode="Redirect" />                
        <error statusCode="500" path="http://www.mywebsite.com/error.html" responseMode="Redirect" />
      </httpErrors>

    </system.webServer>

     <system.web>
        <customErrors mode="On"/>
    </system.web>

</configuration>
1

There are 1 answers

0
Anthony On

This issue can sometimes happen on a shared hosting plan. See, https://forums.asp.net/t/1894946.aspx?Not+getting+custom+error+page, last post:

"You cannot modify the HTTP Error pages on Windows shared hosting plans outside of the 404 error page, which is why you are experiencing the issues"

So, if you have something like this:

<httpErrors errorMode="Custom" existingResponse="Replace">
  <clear />
  <error statusCode="400" responseMode="Redirect" path="/Errors/404error.html" />
  <error statusCode="403" responseMode="Redirect" path="/Errors/404error.html" />
  <error statusCode="404" responseMode="Redirect" path="/Errors/404error.html" />
  <error statusCode="500" responseMode="Redirect" path="/Errors/404error.html" />
</httpErrors>

You'll get the error "The page cannot be displayed because an internal server error has occurred." but if you change it to this:

<httpErrors errorMode="Custom" existingResponse="Replace">
  <remove statusCode="404" />
  <error statusCode="404" responseMode="Redirect" path="\Errors\404error.html"/>            
</httpErrors>

It will work.

A full discussion of why this happens on GoDaddy can be found on this old forum thread here: https://web.archive.org/web/20130131011933/https://support.godaddy.com/groups/web-hosting/forum/topic/custom-http-error-pages-on-4gh-windows-shared-hosting/ .

There lots of other issues why your custom errors may not be working, but this particular one doesn't seem to be well documented, so I thought I'd post it here for others.