1

We are using Sitecore 9.0.2 and SXA 1.7.1

We have configured a server error page in the field called "Server Error Page Link" in the "Settings" item. We generated the static error page (navigate to site inside "Site Grouping" and in Error Handling tab in ribbon click "Generate static error page").

I have a page where I just throw an exception in code and when I hit that page it should be redirected to the server error page. This approach is working fine in local but not working on the Dev environment, which is set up in Azure PaaS.

In local, it is working fine irrespective of CustomErrors mode value. I tried all the modes in Dev, even published the whole site but no luck.

Is there any extra step for Azure PaaS to make it work?

in Dev, customErrors mode is "RemoteOnly". The error is below.

Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine. 

I found one difference, it is creating a folder called "ErrorPages" in the site root folder and one error HTML page inside this folder in local which is not happening in Dev.

The process to setup server error page in SXA: http://zhenyuan.azurewebsites.net/category/sxa

Thanks.

4
  • What do you mean with "it is not working'"? What is the result you get?
    – Gatogordo
    Commented Mar 15, 2019 at 9:54
  • it is not redirecting to sever error page when exception occurred in code. I have updated post with result. thanks a lot for quick response.
    – Erwin Paul
    Commented Mar 15, 2019 at 10:05
  • You need to set customErrors to "off"
    – Mark Cassidy
    Commented Mar 15, 2019 at 13:01
  • making customErrors to "off" not working. it is displaying detailed asp.net error. thanks a lot for response.
    – Erwin Paul
    Commented Mar 15, 2019 at 13:30

1 Answer 1

1

There is now official documentation for this available here. However I will extend it with some extra steps that I think are needed. I've tested with 9.0.2 and SXA 1.7.1, as well as with 9.1.0 and SXA 1.8.0 on Azure PaaS.

  1. Create your error page item.
  2. Publish the error page item.
  3. Navigate to sitecore/Content/Tenant/Site/Settings and in the Error Handling section insert the link to your custom error page. If you cannot find the Error Handling section, you may have need to select the Error Handling option when creating your tenant.
  4. Navigate to /sitecore/Content/Tenant/Site/Settings/Site Grouping/Site and in the ribbon, on the Error Handling tab, click Generate static error page and click Ok

When you click the "Generate static error page" button on the Site grouping site, you should see logs like this on the CM server:

INFO HTTP 500 request page URL: https://...azurewebsites.net/500

INFO HTTP 500 page has been succesfully rendered to /ErrorPages\Site.html

  1. It will not automatically copy the .html file to CD servers, so I would recommend you check in the .html file into your solution (for example, in Project.Site layer if you're using helix) so that the static page will be deployed to all servers.

Notes and Troubleshooting

Something to note is that SXA will not be affected by any setting of customErrors in the web.config. If you need to disable the custom errors page functionality on local development, then you'll need to unlink the Error page from settings and delete the static .html file.

If it's still not working, then SXA will log similar as follows:

Could not find proper static error page for site: site. Please generate it.

In this case, please double check your .html file is present in /ErrorPages/Site.html.

Another possible reason it won't work is if it's resolving the Site Context incorrectly. In this case use the Site Manager to check your site grouping settings are correct.

If you are getting an HTTP 405 response when you POST a form and IIS blocks the request (for example if you have <script> tag in the request), then the only way I've found to fix this is to add a .html file handler to your web.config as per this answer. However, I haven't fully tested this so it is up to you to determine it won't affect any other functionality.

<add name="html" path="*.html" verb="*" modules="IsapiModule" scriptProcessor="%windir%\system32\inetsrv\asp.dll" resourceType="Unspecified" requireAccess="None" />

Your Answer

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

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