Synopsis
By modifying the web.config file, you can create custom error pages so that when errors are encountered, your customers see friendlier notices than server errors and basic 404- and 500-type errors.
Procedure
First, find the "customErrors mode" section of the web.config file. That can be changed to "On" (displays your custom pages to all viewers), "RemoteOnly" (displays custom errors to remote viewers, and the actual error to local viewers for debugging purposes), or "Off" (displays ugly error messages to everyone).
You can specify the custom error page(s) in 2 ways:
- A line like <customErrors mode="RemoteOnly" defaultRedirect="/error.html"/> will direct any customers who get an error to www.yoursite.com/error.html. You can create a friendly generic "an error was encountered" page to cover all issues.
- You can specify a redirect page for each error type like this:
<customErrors mode="RemoteOnly">
<error statusCode="403" redirect="/accessdenied.html" />
<error statusCode="404" redirect="/pagenotfound.html" />
</customErrors>
You will also want to add this section for non-ASP errors (just before the system.webServer closing tag):
<httpErrors errorMode="Custom">
<remove statusCode="404" />
<error statusCode="404" path="/PageNotFound.aspx" responseMode="Redirect" />
</httpErrors>
</system.webServer>
NOTE: You can add other error codes as needed.