Copied to clipboard

Flag this post as spam?

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


  • Stefan 117 posts 215 karma points
    Jan 04, 2012 @ 12:57
    Stefan
    0

    Custom error pages

    Hi.

    I have just added some custom error pages to my Umbraco node tree. I have followed instructions found for assigning custom error pages, but I cant get them to work.

    I have added the node to umbracoSettings.config for error404, but for some reason I'm still left with the default 404 page. I wonder if there are more settings that have to be added somewhere or if something has to be restarted for them to work?

    The website is running on Umbraco 4.7.1.

    Best regards
    Stefan

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Jan 04, 2012 @ 14:01
    Jan Skovgaard
    1

    Hi Stefan

    Can you show us how you have configured the pages in the config file? Might be a syntax thing that is teasing.

    Also try to recycle the app pool.

    /Jan

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jan 04, 2012 @ 14:13
    Tom Fulton
    1

    Hi Stefan,

    I've never used that setting but have heard some mixed results about it.  Instead I ususally just use IIS to use a custom page for 404 errors, by adding this to the web.config:

      <system.webServer>
            ...................
            <httpErrors>
                <remove statusCode="404" subStatusCode="-1" />
                <error statusCode="404" prefixLanguageFilePath="" path="/your-error-page" responseMode="Redirect" />
            </httpErrors>
      </system.webServer>

    Seems to work fine for me.  The only catch is to make sure your error page template doesn't have any 404's (missing images, etc) because it can cause a bit of a loop and slows things down.

    -Tom

  • Stefan 117 posts 215 karma points
    Jan 04, 2012 @ 15:17
    Stefan
    0

    Thank you for your input on this.

    I was writing my reply, when I just thought of looking through web.config (to investigate Tom Fultons suggestion), where I found the property  

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

    Setting the mode to "On" solved the problem :)
    - I find it rather strange that not one of the forum posts I have read mentioned anything about that in web.config.

    Thanks!

  • Stefan 117 posts 215 karma points
    Jan 04, 2012 @ 15:41
    Stefan
    0

    Hm, I might have submitted my post too fast...

    When clicking a link to a node that has no template assigned to it, the 404 errorpage is shown.

    If I enter a random url (eg. mydomain.com/what-ever) I expect the custom erorpage to be shown.
    Instead I'm directed to the custom errorpages of IIS.

    In Plesk controlpanel I can see that custom error pages are set to "On", and I dont know if that can interfere
    with Umbraco somehow?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Jan 04, 2012 @ 20:52
    Jan Skovgaard
    0

    Hi Stefan

    I don't think that the cusom errors value has anything to do with the error 404 pages. I think you saw a change because you touched the web.config, which recycles the application and makes changes done in umbracoConfig.config and in XSLT files etc. appear...like when you've made some changes in a stylesheet but they don't appear untill you clear the browser cache.

    I would really still like to see how you wrote it in umbracoSettings.config becaue I suspect that two things might be the issue

    1) You're trying to set multiple 404 pages for the same culture - if that is the case you'll need to install uComponents and use their 404 handler, which supports this

    2) You're getting the syntax for setting multiple 404 pages with different cultures wrong (That's what I did yesterday).

    The solution for multiple 404 pages with different cultures are to write it like this:

        <errors>
          <error404>
            <errorPage culture="default">1773</errorPage>
            <errorPage culture="en-US">1774</errorPage>
            <errorPage culture="de-DE">1775</errorPage>
          </error404>
        </errors>

    I must admit that I've never used IIS to handle this and I've never used plesk so I don't have any clues on what you need to tryout there. But perhaps the above can solve this for you 100%?

    /Jan

  • Stefan 117 posts 215 karma points
    Jan 04, 2012 @ 21:55
    Stefan
    0

    Okay, I just realized that you're right regarding the customErrors mode. It also works after switching it off.

    This is how it looks in umbracoSettings.config

            <errors>
                <error404>
                    <errorPage culture="default">1397</errorPage>
                    <errorPage culture="da-DK">1397</errorPage>
                    <!-- <errorPage culture="en-US"></errorPage> -->
                </error404>   
            </errors>

    With that config, the errorpage shows up just fine when navigating a node that has no template assigned.
    When navigating to the url of an unpublished node or random text, the standard error page is displayed.

    When running a single language website, wouldnt it suffice to add <errors><error404>node-ID</error404></errors>?

    I assume that the errorpage shown, is related to the webserver and not Umbraco,
    since it does not say "This page is intentionally left ugly ;-)"

    Any clues?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Jan 04, 2012 @ 22:03
    Jan Skovgaard
    0

    Hi Stefan

    Yes when you're only dealing with one 404 page what you suggest is enough.

    Hmm, it should not be possible to navigate to a unpublished node? If it's not published it does not have any URL If it has been published and the node has since been changed then it of course has a url but would also exist so it should be displayed.

    if the node does not have a template assigned then it will not be visited unless you for some reason link to published nodes that does not have any template assigned, which would not make much sense?

    I don't know how to deal with it though but I must admit I don't see it as a big issue since I can't imagine a scenario where you would point people to a node, with no template assigned.

    /Jan

  • Stefan 117 posts 215 karma points
    Jan 04, 2012 @ 22:14
    Stefan
    0

    Well, when no template is assigned and you follow a link to that particular node, the errorpage is displayed.

    The issue is that I would like the 404 page to "catch" all requests to pages that does not exist.
    As of now, it only works in the case just mentioned, which is as you say, not a desired functionality.

  • PBrack 20 posts 42 karma points
    Jan 09, 2012 @ 11:13
    PBrack
    2

    Just to give you a bit more info on this, I've recently done some work formalising an error approach, and you'll probably find you get the same result with default config:

    -http://yourdomain/notapage.aspx - this will go to your umbraco 404 page, as it is handled by Umbraco

    -http://yourdomain/notapage.jpg, http://yourdomain/notapage.jpg - these aren't handled by .net (and therefore not by Umbraco), so you get the IIS 404

    -http://yourdomain/umbraco/notapage.aspx - this isn't handled by Umbraco, as they're within a directory excluded from Umbraco's routing, but because of the .aspx extension, it is handled by .net, so you'll get your default .net 404.

    That's three diferent 404s...

    While it seems like a pain, I'd suggest it's good practice to get ALL of these to 404 to the same Umbraco page - I'd set this page up in your web.config and in IIS also

Please Sign in or register to post replies

Write your reply to:

Draft