How to configure a Web.Config file to allow custom 404 handling while still displaying on-page 500 e
Posted
by Mark
on Server Fault
See other posts from Server Fault
or by Mark
Published on 2009-09-23T18:32:54Z
Indexed on
2010/03/29
12:03 UTC
Read the original article
Hit count: 414
To customize 404 handling and based on the hosting company's suggestion, we are currently using the following web.config setup. However, we quickly realized that with this configuration, any page error (500 error) are also getting redirected to this custom error page. How can I modify this config file so we can continue to handle 404 with custom file while still able to view on-page error?
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.webServer>
<httpErrors errorMode="DetailedLocalOnly" defaultPath="/Custom404.html" defaultResponseMode="ExecuteURL">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/Custom404.html" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
<system.web>
<customErrors mode="On">
<error statusCode="404" redirect="/Custom404.html" />
</customErrors>
</system.web>
</configuration>
© Server Fault or respective owner