2

I am facing an issue whereby custom errors are not redirecting to error page configured.

I have custom errors remote only set in the web.config as below:

<customErrors mode="RemoteOnly" xdt:Transform="Replace" redirectMode="ResponseRewrite">
        <error statusCode="500" redirect="/ErrorPage.aspx" />
</customErrors>

And an ErrorPage.aspx within the root of the application. It appears that this is not being caught though.

Is there something different within Sitecore 10 that prevents this to previous versions?

3 Answers 3

0

Your config looks correct, I have pulled the config below from a working Sitecore 10.1 solution.

<customErrors mode="RemoteOnly" defaultRedirect="/500" redirectMode="ResponseRedirect">
  <error statusCode="500" redirect="/500" />
</customErrors>

Is the config you have posted from the transform file? Or is that the resulting content from the web.config? If so, please try removing the xdt:Transform="Replace" as this should not be present.

4
  • Will /ErrorPage.aspx be served with Server error 500? Should that not be a static html file instead?
    – Julius A
    Oct 5, 2022 at 11:52
  • @JuliusA I tried with .html, this current project is a migration from 7.2, it is using an aspx file there so I have dropped it into the new solution.
    – Sean T
    Oct 5, 2022 at 12:01
  • @Julius A - In our situation we redirect 500 error to a published Sitecore page (/500). The controller rendering served on that page gives friendly response to the error. I believe the .aspx should work just as well. Oct 5, 2022 at 12:15
  • If there is Server error, server won't serve the .aspx, hence falling back to static html
    – Julius A
    Oct 6, 2022 at 15:07
0

Recently I did the similar configuration for 404 error page redirection by using below setting in 10.1 version:

<httpErrors errorMode="Custom">
<remove statusCode="404" />
<error statusCode="404" path="404.html or 404.aspx or 404.htm" responseMode="File" />
</httpErrors>

I hope the same works for you by just changing the status code.

Refer to this link for more details on custom error display from Sitecore item and File.

3
  • Thanks, will take a look at using httpErrors instead and report back
    – Sean T
    Oct 6, 2022 at 11:03
  • 1
    This solution will not work for 500 errors as per Microsoft documentation
    – Sean T
    Oct 6, 2022 at 13:28
  • If there is Server error, server won't serve the .aspx, hence falling back to static html in such scenarios.
    – Julius A
    Oct 6, 2022 at 15:08
0

It appears that using the redirectMode="ResponseRedirect" attribute uses Server.Transfer behind the scenes so relative routes will not work with the older .net MVC 4.8 framework. This is not a Sitecore specific issue.

I managed to get it to trigger by removing redirectMode attribute and adding responseMode="file", this allowed me to serve a static html page.

Transform snippet is as follows...

<customErrors mode="RemoteOnly" xdt:Transform="Replace" defaultRedirect="/ErrorPage.html" >
    <error statusCode="500" redirect="/ErrorPage.html" responseMode="File"/>
</customErrors>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.