Custom error messages allow friendly or informative responses by providing a file, execution resource, or redirection to a URL when a site visitor cannot access the content they requested.
By default, IIS provides error messages that are defined in files stored in the Systemroot\help\iishelp\common folder. You can create custom error messages for users and configure IIS to return the page every time a specific HTTP error is encountered on the site.
Note: The following HTTP error messages cannot be customized: 400, 403.9, 411, 414, 500, 500.11, 500.14, 500.15, 501, 503, and 505.
(i) Creating a custom HTTP error response
IIS can return a custom error message whenever an HTTP error occurs. Custom error messages can provide more friendly or richer feedback than the default error message.
1. Open IIS Manager, and then navigate to the level you want to manage.
2. In the function view, double-click error page.
3. In the actions pane, click Add.
4. In the Add Custom Error page dialog box, under Status Code, type the number of the HTTP status code for which you want to create a custom error message.
5. In the Response Action box, do the following:
-Select "Insert content in static file into error response" to provide static content (for example,. html files) for custom errors.
-select "Execute URL on this site" to provide static content for custom errors (for example,. asp files).
-Select "Redirect in 302" to redirect the client browser to another URL that contains the custom error file.
6. In the File path text box, if you selected "Insert content in a static file into an error response", type the path to the custom error page, and if you are using the "execute URL on this site" or "Respond with 302 redirect" path type, type the URL of the custom error page, and then click OK.
Note: If "execute URL on this site" is selected, the path must be a URL relative to the current site's root directory. For example, if you need to use the URL "http://contoso.com/products/new/error.htm", you should specify "/products/new/error.htm".
Note: If you select Execute URL on this site, you must ensure that the specified URL is in the same application pool as the URL where the error may occur, or the server will return the 403 no access message. If you cannot guarantee that the specified URL will be in the same application pool as all URLs where the error may occur, select "REDIRECT Responses as 302" and specify a fully qualified URL.
(ii) Change the status code of the HTTP error response in IIS 7.0
If you want to change the HTTP error returned by a custom error response, you can change the status code for the HTTP error response.
1. Open IIS Manager, and then navigate to the level you want to manage.
2. In the function view, double-click error page.
3. On the Error page page, click to select the custom error page whose status code you want to change.
4. In the actions pane, click Change Status Code.
5. On the error page page, in the Status Code column, enter a new status code, and then click anywhere on the page.
(iii) Editing of custom HTTP error responses
When you change the location of a custom error file, you can change the setting of that custom error to point to the new location. Similar actions can be performed when the file type of the error message changes, for example, from a static file to a file that serves dynamic content that is customized for each visitor.
1. Open IIS Manager, and then navigate to the level you want to manage.
2. In the function view, double-click error page.
3. On the Error page page, click the error you want to change to select it.
4. In the Actions pane, click Edit.
5. In the Edit Custom Error page dialog box, select one of the following options:
-Inserts the contents of the static file into the error response, select this option if the error content is static (for example, an. html file).
-Executes URLs on this site, select this option if the error content is dynamic (for example,. asp files).
-redirect The response in 302, select this option if you want to redirect the client browser to a different URL.
6. If you select "Insert content in static file into error response" as the path type, type the path to the custom error page in the File path text box. If you use the "Execute URL on this site" or "Respond with 302 redirect" path type, type the URL of your custom error page instead. Click OK.
(iv) Delete custom HTTP error responses
If you no longer need to return a custom response for a specific HTTP request, you can delete the custom error. You can delete custom errors at the local level, or you can delete custom errors inherited from the parent. After you delete the custom error, IIS returns the default HTTP error message associated with the error.
1. Open IIS Manager, and then navigate to the level you manage
2. In the function view, double-click error page.
3. On the Error page page, select the error you want to delete, and then in the Actions pane, click Delete, and then click Yes.