IMPORTANT: This version of Sitefinity CMS is out of support and the respective product documentation is no longer maintained and can be outdated. Use the version selector to view a supported product version.
Adding a custom error page in your web application is crucial for your site. Otherwise, when your system fails or a page is not found, your users will see the standard IIS "yellow screen of death". The solution is to add custom error page to your web application.
Follow the steps in this article in order to configure custom error pages in your Sitefinity CMS web application.
To configure the display of custom error pages, follow the procedure:
<
httpErrors
errorMode
=
"Custom"
>
clear
/>
remove
statusCode
"403"
subStatusCode
"-1"
"404"
"500"
error
path
"/error-pages/403"
responseMode
"ExecuteURL"
"/error-pages/404"
"/error-pages/500"
</
customErrors
mode
"RemoteOnly"
redirect
"~/error-pages/403"
"~/error-pages/404"
"~/error-pages/500"
If you plan to use any Sitefinity CMS page as a custom error page, you must change the response status explicitly. The default is 200, instead of 400 and this is misleading for the search engines and SEO practice.
To do this, perform the following:
public
partial
class
NotFoundStatusCodeSetter : System.Web.UI.UserControl
{
protected
override
void
Render(HtmlTextWriter writer)
if
(!
this
.IsDesignMode())
base
.Render(writer);
Response.Status =
"404 Not Found"
;
Response.StatusCode = 404;
}
The code above sets the response statues code to 404 only on the frontend. This is handled by the IsDesignMode method. You must add the status code at a latest possible moment - in this sample, in the Render event.
The proper response status code is displayed when requesting a page that cannot be found.
Back To Top
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important