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.
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.
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.
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.).
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.
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?
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.
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?
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:
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.
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?
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.
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.
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.).
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.
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>
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.
is working on a reply...