For error page handling, normally there is 404 page and 500 pages. For 500 pages however, there are errors only happen on particular pages and errors happening on every page, which means if it’s the second case, a dynamic asp.net page won’t work for an error page since it will be broken too. That’s why it’s good practise to setup a static html version of the 500 error page.
For Sitecore SXA, it’s pretty easy. Just follow official documentation here https://doc.sitecore.com/developers/sxa/18/sitecore-experience-accelerator/en/generate-a-custom-static-error-page.html
However few things worth saying here:
- Things the documentation didn't say:
- It works only for CM instance (or standalone of course). Meaning it only generates the html file on the instance you run the command.
- For CD, item needs to be published and files needs to be manually copied over from CM. Publishing is more for the setting purpose I think, and the static html files are under wwwroot/ErrorPages folder.
- Potenially error on Azure
- If you setup IP access restrictions for your Azure Web App (which is recommended for CM role), you need to whitelist the websites' IP to allow the generation since it’s just calling the 500 content page via http(s) calls.
- To get the website’s server IP, you can do so in KUDO using powershell: (New-Object Net.WebClient).DownloadFile('https://api.ipify.org/?format=json', 'ip.txt’), then just view the content of the ip.txt file.
- You can also create an inline aspx page to do similar things, up to you...