Creating Custom Error Pages

Mike Bilz asked on July 7, 2017 20:48

Hello Kentico Team,

I am a little stuck on how to create custom error pages for 500 and 503 errors.

Should I copy the existing Error.aspx page and alter it's code-behind file to make the error messages less specific? Or can I just create a simple aspx page with no code-behind file at all, and include some basic HTML content?

Ideally, these pages should only contain an error code, a description, and a link to the homepage.

Thanks in advance for the help.

-mike

Recent Answers


Brenden Kehren answered on July 7, 2017 21:11

You can create error pages within the Kentico content tree OR you can create your own pages within the file system. In the web.config, go to the <customErrors> node and add in child nodes for each error code and specify the location you want to send them to. For instance:

<error statusCode="500" redirect="~/CMSPages/Custom/500Error.aspx" /> <error statusCode="503" redirect="~/CMSPages/Custom/503Error.aspx" />

0 votesVote for this answer Mark as a Correct answer

Mike Bilz answered on July 7, 2017 23:05

Hi Brenden,

So if I create the pages inside the Kentico Content tree, would those links look like this?

<error statusCode="503" redirect="~/Utilities/Special-Pages/Service-Unavailable" />

Using the "live URL" of the page, or do I need to use the "Permanent URL" for something like this?

Thanks.

-mike

0 votesVote for this answer Mark as a Correct answer

Zachary Perry answered on July 10, 2017 18:25

According to the documentation, It is recommended to add general error pages directly into your web project as .aspx files.

1 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on July 12, 2017 15:12

If you created them inside the content tree, you are correct. I did fail to mention this in my initial post, if your site is down your and someone generates an error, those pages will not render. So in most cases, it's best to create those pages in the file system or upload something to the media library that is an HTML file or something like that which is not dependent on Kentico to process it first.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.