Custom error page even when Sitefinity cannot load.

Posted by Community Admin on 03-Aug-2018 22:07

Custom error page even when Sitefinity cannot load.

All Replies

Posted by Community Admin on 02-Feb-2012 00:00

Hello,

I am working on getting custom error pages implemented for our Sitefinity project.

I have added the following in my web config:

<httpErrors errorMode="Custom" defaultPath="/Error/Error.htm" defaultResponseMode="ExecuteURL">
    <remove statusCode="404" subStatusCode="-1" />
    <error statusCode="404" prefixLanguageFilePath="" path="/NotFound" responseMode="ExecuteURL" />
</httpErrors>

and also:
<customErrors mode="On" defaultRedirect="Error/Error.htm">
 
</customErrors>

Now, in most cases, this works fine. Here is the issue I am having. I am trying to test the "worst case scenario" that Sitefinity is completely broken. To simulate this, I simply disconnect my dev machine from the database used by Sitefinity, and try to reach any page. Obviously, this breaks the application. The problem is, even my error page is not served, and the page is pure HTML! As best as I can understand, html should load no matter what is happening to application. I cannot even browse the error page directly when the application is in this state; all I receive is a YSOD.

I am concerned about this, because it is vital to our client that we present a professional error message in all cases. A loss of database connection is a very real case, and I need to know how to deal with this.

I'm running Sitefinity 4.3, and IIS 7.5

Posted by Community Admin on 06-Feb-2012 00:00

I hate to "bump" a post this way, but I really need an answer for this. Has anyone encountered this before?

Posted by Community Admin on 09-Feb-2012 00:00

Hi,

Could it be that IIS is catching the error and it does not reach to Sitefinity at all. Please see the attached video showing how to set the custom error redirection properly from IIS, and do not hesitate to get back to us if any issues persist.

Kind regards,
Boyan Barnev
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 09-Feb-2012 00:00

Boyan,

Thanks for answering. However, I get a 404 error when I try to view the video you attached. Could you please check your link?

Thanks!

Posted by Community Admin on 09-Feb-2012 00:00

Hi Adam,

I apologize for the inconvenience, please find the video re uploaded and attached tot his response.

All the best,
Boyan Barnev
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 10-Feb-2012 00:00

Boyan,

Thanks for providing the video. It handles 90% of all error cases, the problem I was facing was more complicated. The standard setup outlined in the video, and countless articles, works well enough in the common case that a single page has something has something wrong, but the site as a whole is still functioning.

The case I am dealing with is when the entire Sitefinity application has broken down. This is easy enough to replicate if Sitefinity is on a separate machine from its database. Just sever the connection to the database, and the entire app falls apart. As a test, I placed a simple .jpg in the root directory. When the database was down, I could not even browse the .jpg. Any call to the site resulted in a "yellow screen of death". It appears that Sitefinity routes all requests, even static content like images and html files.

This is tragic in the case of the custom error page, which is under the site directory. In the moment that it is needed most, it cannot be served. I had already taken the step of creating a static custom error page as html, so that it would not rely on Sitefinity for rendering, as my dynamic 404 page does. However, there were still a few more steps required.

<httpErrors errorMode="Custom" defaultPath="Error\Error.htm" defaultResponseMode="File" existingResponse="Replace" >
    <remove statusCode="500" subStatusCode="-1" />
    <remove statusCode="404" subStatusCode="-1" />
    <error statusCode="404" prefixLanguageFilePath="" path="/NotFound" responseMode="ExecuteURL" />
    <error statusCode="500" prefixLanguageFilePath="" path="Error\Error.htm" responseMode="File" />
</httpErrors>


I had to set the responseMode="File" instead of "ExecuteURL". This causes IIS to serve the file directly instead of trying to execute the url, which is important in the case of a server error, because the url may not be able to execute. Next, I had to set existingResponse="Replace". The default behavior is for IIS to serve the custom error, and then pass on the response code (500 in this case). I had to set replace so that it would serve the error page with a 200 message. Why? Because otherwise the site's customErrors section would catch it!

<customErrors mode="On" defaultRedirect="Error/Error.htm">
         
    </customErrors>


Of course, when the customErrors section caught the error, it would try to serve the page through the application, and I would again receive a yellow screen. Replacing the response code prevents the second error handling from being hit at all.

Posted by Community Admin on 08-Jan-2013 00:00

Thanks Adam, It works.

Initially it was not working but as I removed [defaultPath="Error\Error.htm" ] from "httpErrors " tag ,which you mentioned above, I got SF page for 404 error and html page 500 error as expected.

Please mark as asnswered to you post.

Thanks

Posted by Community Admin on 26-May-2014 00:00

Thanks Adam

This thread is closed