0 Comments

Creating a static 500 error page is not something new. SXA provides this feature out of the box.  However, when the first time seeing the settings in SXA, I was thinking why SXA 500 page is configured in CMS. 500 error could be caused by an server error, or database error which means CMS may not be accessible.  Why?  Today,  one of the colleagues asked me the same question, and

Unfortunately, Rare information can be found on the Sitecore documentation site.  After spending an hour looking into the code, we totally understand how it was designed. 

image

Here are the steps to make 500 error page working in SXA:

  1. Configure the Server Error Page – Linking to error page item
  2. Select the “Site Definition” item
    image
  3. Once you click on the Site definition item, the “Error handling” menu will appear in the ribbon
    image
  4. Click on “Generate static error page” button (as shown above)
  5. It will popup an confirmation dialog
    image
  6. Click “Ok” then going to the root of your website in which you can find “ErrorPages”, and the static error page is automatically generated in this folder.
    image

 

When an error occurs, user will be redirected to this static error page. This magic can be found the ErrorHandling pipelines.

image

Overall, I will say it is well designed, although there is a bit of flaw in the above code -  it doesn’t handle the response status.  The Server.TransferRequests does not change the status code, it passes control of the request on to another page without telling the client.  However you can always manually set the status code to 500 by overriding the flaw Process method.

Post comment