Copied to clipboard

Flag this post as spam?

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


  • Ivan 165 posts 543 karma points
    Oct 08, 2012 @ 08:15
    Ivan
    0

    Handling 500 error when Umbraco is down

    Hi guys.

    Is there a way to show user-friendly error message while Umbraco is down (e.g. wrong DB connection).

    Currenty we have the following snippet in the web.config:

    <customErrors mode="RemoteOnly">

    <error statusCode="500" redirect="500.aspx"/>

    </customErrors>

    This one works fine, when a server error occures on the Umbraco application. But when Umbraco is dead, the "500.aspx" is not executed obviosly, and the ugly "yellow screen" comes up.

    Any thoughs?

  • Barry Fogarty 493 posts 1129 karma points
    Oct 08, 2012 @ 14:18
    Barry Fogarty
    0

    The aspx page should render fine once it does not need the Umbraco URL routing engine to process it.  So you should have this error page completely outside the scope of Umbraco altogether, i.e. physically located at /500.aspx on the server, and not dependent on any code within the Umbraco namespaces.

  • Ivan 165 posts 543 karma points
    Oct 08, 2012 @ 14:35
    Ivan
    0

    Is there a way to use the Umbraco page ("500.aspx") while Umbraco is up and running, and show static "500.html" only when Umbraco is dead?

  • Barry Fogarty 493 posts 1129 karma points
    Oct 08, 2012 @ 15:12
    Barry Fogarty
    0

    You could handle this in the codebehind of your fallback 500.aspx, redirecting to the umbraco 500 error page if, for instance, you could return a valid value for the Url property (or whatever) of your Error Page node.  

    Use the NodeFactory API to get a reference to your Umbraco 500 error page:

    var umbracoErrorPage = new Node(your-error-page-node-id);

    Make sure to handle any exceptions thrown using try-catch blocks, so you can render the fallback 500 page OK, i.e. if the DB is not accessible etc.

     

    I guess you could do it the other way around too - redirecting to your fallback 500 page if any exception is thrown during the rendering of your Umbraco 500 page.  The above, I believe, will be more robust as there is less risk an exception will be thown which your code will not catch.

  • Ivan 165 posts 543 karma points
    Oct 08, 2012 @ 16:10
    Ivan
    0

    Thanks for your answer, Barry.

    But I meant to make this done by twiking Umbraco configuration, not programatically - C# is outside of my scope.

    Can you, please, confirm with me that it cannot be done via Umbraco settings? 

  • Barry Fogarty 493 posts 1129 karma points
    Oct 08, 2012 @ 16:19
    Barry Fogarty
    0

    To answer your original question Ivan, yes it is possible see my original reply.  I am not aware of a config-based solution to your follow-up question.

  • Marc Stöcker 104 posts 560 karma points c-trib
    Oct 08, 2012 @ 16:19
    Marc Stöcker
    0

    Ivan,

    to handle the YSOD ("yellow screen of death"), you can use this setting in your web.config:

    <customErrors mode="RemoteOnly" defaultRedirect="errors/fatal.html" />

    Marc.

  • Ivan 165 posts 543 karma points
    Oct 08, 2012 @ 16:31
    Ivan
    0

    Marc,

    I would like to use static (.html) page only when Umbraco is down. Otherwise I would like to use dynamicweb "500.aspx" page (created in Umbraco), because it can output usefull information (e.g. navigation, company email, etc.).

  • Marc Stöcker 104 posts 560 karma points c-trib
    Oct 08, 2012 @ 16:49
    Marc Stöcker
    0

    Isn't the "defaultRedirect" only picked up if no other <error > items or no matching ones are available? Maybe i'm recalling it wrong. Didn't have the time to test it out, sorry.

  • Ivan 165 posts 543 karma points
    Oct 08, 2012 @ 17:13
    Ivan
    0

    Marc,

    Yes, it does. The problem is that ASP.NET always returns error 500, even when Umbraco is down.

    So the following config always tries to process the "500.aspx" page. And never access the "fatal.html"

    <customErrors mode="RemoteOnly" defaultRedirect="errors/fatal.html">

    <error statusCode="500" redirect="500.aspx"/>

    </customErrors>

     

  • Marc Stöcker 104 posts 560 karma points c-trib
    Oct 09, 2012 @ 14:58
    Marc Stöcker
    0

    Sorry, I thought the sub status codes would be different (i.e. 500.1, 500.3, etc.). No idea how to acomplish what you are trying to set up.

Please Sign in or register to post replies

Write your reply to:

Draft