Custom Error Pages - HTTP Error 500.19 - Internal Server Error
This article has been moved to its new home here: https://benperk.github.io/msdn/2012/2012-05-custom-error-pages-http-error-500-19-internal-server-error.html
Rendering custom error pages can be helpful when, for example, the custom error page provides some information on how to resolve the error. Perhaps if a client attempts to access a file which does not exist on the web site, meaning they receive a 404 HTTP status code, you can render a page which has existing similar named files, provide a site search capability or redirect the request to the web sites default page.
Before you can do that, you need to configure the Error Pages on IIS for this. On my IIS 8 instance, the default server level settings can be viewed by clicking the icon as Figure 1 shows.
Figure 1, IIS 8 Custom Error Pages default
Without modification when a client receives a 404 HTTP response, they will receive the message shown in Figure 2.
Figure 2, IIS 8 default 404 error page
Let's say instead of rendering the default 404 page, I want to modify it and make it match the style of my website. To do this, navigate to the "Default Web Site" node, for this example, and double-click on the Error Pages icon in the Features pane. Then click on the 404 found in the Status Code column and then Edit… on the Actions pane as shown in Figure 3.
Figure 3, Edit a Site level Error Page
Next, within the Edit Custom Error Page window, deselect the "Try to return the error file in the client language" check box, set the File path as shown in Figure 4.
Figure 4, Edit Customer Error Page and set the File path
Then select the Edit Feature Settings… from the Actions pane and select the Custom error pages radio button, as shown in Figure 5.
Figure 5, Configure Error Responses
Then browse to the Default Web Site and enter a file that does not exist. When I do this it results in the following:
HTTP Error 500.19 - Internal Server Error
Absolute physical path "C:\inetpub\wwwroot\ErrorPages" is not allowed in system.webServer/httpErrors section in web.config file. Use relative path instead.
That did not seem to work out as expected.
To resolve this error, select the server node within IIS (ex. SERVERNAME\Administrator) and within the Features pane double-click the Configuration Editor icon. Navigate to the system.webServer/httpErrors element, as shown in Figure 6 and change allowAbsolutePathsWhenDelegated
to true, then Apply….
Figure 6, Configuration Editor setting allowAbsolutePathsWHenDelegated
Return to the "Default Web Site" and navigate to a file which does not exist. You will see the custom error page as shown in Figure 7.
Figure 7, a custom, more friendly error page
Comments
Anonymous
May 02, 2012
Clear,Informative and Helpful..Thanks!Anonymous
May 02, 2012
It’s a good knowledge sharing website. I appreciated your work and knowledge. Thank for this.Anonymous
November 30, 2012
thanks :)Anonymous
May 17, 2013
Hi, I have followed step by step this article but i am getting some issues..I have language specific custom error pages. and i am using http errors in web.config.still i am getting default iis error response.I have installed languge pack also. here are the code sniplets of web.config.<httpErrors defaultResponseMode="File" errorMode="Custom" existingResponse="Replace"> <remove statusCode="404" subStatusCode="-1" /> <error statusCode="404" prefixLanguageFilePath="error" path="error.htm"/></httpErrors>i have overidden mode to allow in httperror section in apphostconfig. i have also set custom error mode to off. and i am not using standard ~/Views/Shared/Error.cshtml page.Please suggest me if any other configuration changes needs to be taken care..Anonymous
June 05, 2013
Thank you, this worked! I had to enable allowAbsolutePathsWhenDelegatedI was getting error 500.19Anonymous
October 21, 2013
From www.morgantechspace.com/.../http-error-50019-internal-server-error.htmlASP.Net applications come pre-wired with a handlers section in the web.config. By default, this is set to readonly within feature delegation within IIS. Take a look in IIS Manager1.Go to IIS Manager and click Server Name2.Go to the section Management and click Feature Delegation.3.Select the Handler Mappings which is supposed to set as readonly.4.Change the value to read/write and now you can get resolved the issueAnonymous
June 14, 2015
Thanks for this - nearest I've got to making IIS work like a proper webserver. Shame I can't use the most important step though. I'm unable to change the value for allowAbsolutePathsWhenDelegated - how do I unlock it?Anonymous
July 29, 2015
@Hippyjim, you can use the Configuration Editor and click on the Unlock Action link. HTHAnonymous
July 29, 2015
@Hippyjim, you can use the Configuration Editor and click on the Unlock Action link. HTHAnonymous
August 27, 2015
Love the pictures and detailed instructions on fixing this issue. I like this method better than manually editing the application.host file. Now I can finally configure a nice custom 404 error page.