I would appreciate any help in this case.
I have a .NET Framework 4.5.1 web app running on IIS. I have two physical files in the root of this app:
Error404.html
Error500.html
In the web.config under "system.web" I created this configuration to serve custom error pages from .NET Framework:
<customErrors mode="RemoteOnly" defaultRedirect="/Error500.html" redirectMode="ResponseRewrite">
<error statusCode="404" redirect="/Error404.html" />
<error statusCode="500" redirect="/Error500.html" />
</customErrors>
In the web.config under "system.webServer" I created this configuration to serve custom error pages from IIS web server:
<httpErrors errorMode="DetailedLocalOnly" existingResponse="Auto">
<remove statusCode="404" />
<remove statusCode="500" />
<error statusCode="404" path="/Error404.html" responseMode="ExecuteURL"/>
<error statusCode="500" path="/Error500.html" responseMode="ExecuteURL"/>
</httpErrors>
My goal is to prevent to see detailed errors from internet (internet users). However I want to see detailed errors on my localhost.
So until this point, everything is working just fine. However when I change a connection string in my web.config to a host which doesn't exist (TCP Provider, error: 0 - No such host is known.), these rules for custom error pages are not working anymore.
From internet I get this error instead of my custom error page:
Server Error in '/' Application.
Runtime Error
Description: An exception occurred while processing your request. Additionally, another exception occurred while executing the custom error page for the first exception. The request has been terminated.
Why I can't see my custom error pages from internet?