Copied to clipboard

Flag this post as spam?

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


  • Glen Peters 24 posts 115 karma points
    Feb 16, 2017 @ 18:23
    Glen Peters
    0

    Umbraco 7.5 Custom 404 Handling

    Hi all. I have not seen any posts about best practice in 7.5 and above for properly configuring custom 404 handling. Someone in the know, please update this as the old way of writing into the web.config seems to break now.

    The resource page has not been completed: https://our.umbraco.org/documentation/Reference/Config/404handlers/

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Feb 16, 2017 @ 18:35
    Morten Bock
    0

    I think you're looking for the IContentFinder interface

    https://our.umbraco.org/documentation/reference/routing/request-pipeline/icontentfinder

  • Glen Peters 24 posts 115 karma points
    Feb 16, 2017 @ 18:48
    Glen Peters
    0

    Thanks for your response Morten. I don't think that site designers/developer should have to modify and compile code for something as simple as setting up 404 handling. At least, I don't think of it as simple. I don't feel that this counts as a "best practice" approach, but I guess it is a way of doing it.

    Surely there is an easier method. There has to be a .config file approach that works.

  • Ian 178 posts 752 karma points
    Feb 16, 2017 @ 19:28
  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Feb 16, 2017 @ 20:04
    Morten Bock
    0

    In the umbracoSettings.config there is an Errors section

    https://our.umbraco.org/documentation/Reference/Config/umbracoSettings/#errors

    That lets you define content pages that should be shown if no content was found.

    Is that the kind of thing you're looking for?

  • William Charlton 171 posts 218 karma points
    Jan 03, 2018 @ 12:04
    William Charlton
    0

    Morten, I am having the same problem. I have created a 404 page with the ID of 1114. I have modified my umbracoSettings.config as below:

    <errors>
          <error404>1</error404>
          <!-- 
            The value for error pages can be:
            * A content item's integer ID   (example: 1234)
            * A content item's GUID ID      (example: 26C1D84F-C900-4D53-B167-E25CC489DAC8)
            * An XPath statement            (example: //errorPages[@nodeName='My cool error']
          -->
          <!--
            <error404>
                <errorPage culture="default">1</errorPage>
                <errorPage culture="en-US">200</errorPage>
            </error404>
           -->     
            <error404>1114</error404>      
        </errors>
    

    and added

    <httpErrors existingResponse="PassThrough" />
    

    to my web.config - but I still get a blank, deliberately untidy 404 page.

    Having posted this I can now see my error in black and white! So I think it is worth leaving here. Tip: the web-server uses the first <error404/> it comes to, in this case page ID 1 :)

  • Glen Peters 24 posts 115 karma points
    Mar 04, 2019 @ 22:05
    Glen Peters
    101

    I recently discovered that if I configure the umbracoSettings.config file as follows, it works:

      <content>
        <errors>
          <error404>1968</error404>
    

    If you replace the "1968" with the numerical page ID of your custom 404 page, then you will be able to have your error page handle the errors.

    William Charlton Your issue is that you did not replace the default value of 1 in the second line of your sample. That line has to be replaced with your ID as follows:

    <error404>1114</error404> 
    

    Can't believe it took me this long to figure out. I think that the content of the https://our.umbraco.org/documentation/Reference/Config/umbracoSettings/#errors page is not explicit enough in explaining how this works.

Please Sign in or register to post replies

Write your reply to:

Draft