Configure Custom Error Messages in ASP.NET in Cloud Sites
Note: |
The script provided below is only an example. As outlined in our Terms of Service and our article Management and Support Levels, we are unable to help you troubleshoot code and script issues. We recommend speaking with your developer before implementing any script functionality. |
You can enable custom error messages for your ASP.NET application on Windows IIS by using a web.config file with a customErrors setting configured.
Warning: |
For security purposes and coding best practices, set the customErrors mode to RemoteOnly or On instead of Off. The Off mode is primarily useful for debugging, and it should not be used in a production environment because of the details that it can expose about your server. |
To configure a custom error page for ASP.NET 3.5 SP1 and later, follow this example:
<configuration>
<system.web>
<customErrors mode="On" redirectMode="ResponseRewrite" defaultRedirect="~/error.aspx" />
</system.web>
</configuration>
The following example is for ASP.NET 2.0 to 3.5 without SP1:
<configuration>
<system.web>
<customErrors mode="On" defaultRedirect="~/error.html" />
</system.web>
</configuration>