• Sales: 1-800-961-2888
  • Support: 1-800-961-4454

How Do I Setup customErrors In ASP/.NET on Cloud Sites?


You can enable custom error messages for your ASP .NET application defaulted to Windows/IIS by using a web.config file with a "customErrors" setting configured.

We have included example web.config files below.  For more detailed information refer to http://msdn.microsoft.com/en-us/library/h0hfz6fc.aspx


For Security purposes and coding best practices you should have the web.config customErrors mode="RemoteOnly" or mode="On" instead of mode="Off".  The "Off" mode is primarily useful for debugging, and should not be used in a production environment because of the details it can expose about your server.

To configure a custom error page for 3.5 SP1 and above, follow this example:

<configuration>
   <system.web>
      <customErrors mode="On" redirectMode="ResponseRewrite" defaultRedirect="~/error.aspx" />

   </system.web>
</configuration>

This example is for ASP.NET 2.0 - 3.5 without SP1:

<configuration>
       <system.web>
          <customErrors mode="On" defaultRedirect="~/error.html" />

       </system.web>
    </configuration>

ASP.NET Security references:



© 2011-2013 Rackspace US, Inc.

Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License


See license specifics and DISCLAIMER

2 Comments

The first block of code shows OFF, but then immediately after the article states we should use ON or REMOTEONLY. This is quite confusing and should be written more clearly. Does this mean that the first part is to get detailed errors to show and the rest is what should be used in a production environment?

Not a bad point. Thanks, Phil. We'll see if we can't word that better. How you read it is correct - the "off" setting is good for getting detailed errors for debugging purposes, but it can expose more information about the server than you might like for a site in production.

Add new comment