We want to set up a friendly error page for a Sitecore application. We created a new htm page in root folder and used IIS custom errors (using web.config's custom errors element) to redirect errors to that page. Its not working for some server errors. For some server errors it is not reliable at all. Sometimes it works and sometime it shows server error in '/' application. This is in IIS 8.5.
Coming to our testing environment its IIS 7.5. Here when we use custom errors of IIS (using web.config's custom errors element) it is not working at all for any server errors.
Is this the correct way. if it is, please tell us what is going wrong here. If not please suggest us the correct way. Thanks in advance :-)
As suggested by @jammykam I did try http errors method suggested in this link: How do you setup a 404 and 500 error page for missing files and media items? . This method redirects me to the error page for all 500 and 404 errors but images in the error page are not loading. Instead of images, 'x' marks are showing up. I tried the following code in web.config:
<httpErrors errorMode="DetailedLocalOnly" existingResponse="Replace">
<remove statusCode="404" subStatusCode="-1" />
<remove statusCode="500" subStatusCode="-1" />
<error statusCode="404" path="C:/site_path/ErrorPage/ErrorPage.htm" responseMode="ExecuteURL" />
<error statusCode="500" path="C:/site_path/ErrorPage/ErrorPage.htm" responseMode="File" />
</httpErrors>
<!-- Disable for IIS 7+ -->
<customErrors mode="Off" />
where I created new error page folder in the IIS website root folder which includes ErrorPage.htm (htm web page) and image required for it. Web page loads perfectly fine when opened with any browser separately.
Not sure why the images are showing up as 'x' marks. Is it the problem with file response mode in http errors? Please help, thank you. Edit2 as per the request in comment: Html code is:
<body>
<img src="errorImage.png">
</body>
Where errorImage.png and ErrorPage.htm are in a folder named ErrorPage
I also tried the following html code:
<body>
<img src="C:/ErrorPage/errorImage.png">
</body>
which shows up only blank page without any 'x' mark.
When using the following code in web.config with AllowAbsolutePathWhenDelegated=false in iis at server level
<httpErrors errorMode="DetailedLocalOnly" existingResponse="Replace">
<remove statusCode="404" subStatusCode="-1" />
<remove statusCode="500" subStatusCode="-1" />
<error statusCode="404" path="/ErrorPage/ErrorPage.htm" responseMode="ExecuteURL" />
<error statusCode="500" path="/ErrorPage/ErrorPage.htm" responseMode="File" />
</httpErrors>
<!-- Disable for IIS 7+ -->
<customErrors mode="Off" />
The error page is not loading. Please help.
../../img/error.png
or absolute path like/assets/img/error.png
?