Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Andrew Gibson 16 posts 107 karma points
    Dec 05, 2017 @ 16:43
    Andrew Gibson
    0

    custom 404 for variety of url errors

    I followed this tutorial

    so in umbracoSettings.config I have

    <errors>
      <error404>1226</error404>
        <error404>
            <errorPage culture="default">1</errorPage>
            <errorPage culture="en-US">200</errorPage>
        </error404>
    </errors>
    

    plus this

      <web.routing
        trySkipIisCustomErrors="true"
        internalRedirectPreservesTemplate="false" disableAlternativeTemplates="false" disableFindContentByIdPath="false"
        umbracoApplicationUrl="">
      </web.routing>
    

    which notes in the file suggest to skip IIS custom errors.

    I also attempted adding a section to the bottom of the root web.config, as suggested:

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

    Note that I am working locally.

    With just these settings (with or without the last mentioned web.config addition) my 404 page works, and displays, for nonsense such as 'http://localhost:61239/wibble'. This is fine.

    If I go to 'http://localhost:61239/wibble.cshtml' I get "This type of page is not served. Description: The type of page you have requested is not served because it has been explicitly forbidden."

    But if I go to 'http://localhost:61239/views/wibble.cshtml' I get another 404: "The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed..."

    Please tell me what additional settings, or amendments, I need in the web.config to get my 404 page working for these difference circumstances?

    P.S. I've tried all kinds of combinations of an added system.webServer block in web.config, as the following indicates, but none have changed the above-described behaviour:

      <!--<system.webServer>
        --><!--<httpErrors existingResponse="PassThrough">
          <remove statusCode="404" subStatusCode="-1" />
          <error statusCode="404" prefixLanguageFilePath="" path="~/Views/mscb404page.cshtml" responseMode="ExecuteURL" />
        </httpErrors>
        <httpErrors existingResponse="PassThrough" >
          <remove statusCode="404" subStatusCode="-1" />
          <error statusCode="400" path="/404" responseMode="ExecuteURL" />
          <error statusCode="404" path="/404" responseMode="ExecuteURL" />
      </httpErrors>--><!--
      </system.webServer>-->
    

    (There are also existing system.webServer sections, so I'm not sure if any changes need to be applied to one of these sections, or a completely new system.webServer section.)

Please Sign in or register to post replies

Write your reply to:

Draft