Wednesday 23 October 2013

Disabling custom errors using TrySkipIisCustomErrors

HttpResponse.TrySkipIisCustomErrors Property can be used to enable / disable custom errors on IIS 7.0

The TrySkipIisCustomErrors property is used only when your application is hosted in IIS 7.0. When running in Classic mode in IIS 7.0 the TrySkipIisCustomErrors property default value is true. When running in Integrated mode, the TrySkipIisCustomErrors property default value is false.

HTTP Errors

The <httpErrors> element allows you to configure custom error messages for your Web site or application. Custom error messages let you provide a friendly or a more informative response by serving a file, returning another resource, or redirecting to a URL when visitors to your site cannot access the content they requested. For example, you might want to customize each of the error message pages for your Web site to have the same look and feel as the rest of your site.

The <httpErrors> element contains a collection of elements, each of which defines an error message that IIS uses to respond to specific HTTP errors. You can add custom error messages to IIS by adding an <error> element to the <httpErrors> element in the Web.config file for your site, application, or URL. Each element uses the responseMode attribute to specify whether IIS serves static content, dynamic content, or redirects to a separate URL in response to an error.

Example HTTP Errors configuration

<system.webServer>
<httpErrors>
<error statusCode="404" prefixLanguageFilePath="" 
path="/404Error" responseMode="ExecuteURL" />
<error statusCode="410" path="/410Error" 
responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>

Read more >>

No comments:

Post a Comment