Export (0) Print
Expand All

CustomErrorCollection Class

Represents a collection of CustomError objects. This class cannot be inherited.

Namespace:  System.Web.Configuration
Assembly:  System.Web (in System.Web.dll)

[ConfigurationCollectionAttribute(typeof(CustomError), AddItemName = "error", 
	CollectionType = ConfigurationElementCollectionType.BasicMap)]
public sealed class CustomErrorCollection : ConfigurationElementCollection

The CustomErrorCollection type allows access to the error elements of the customErrors section element collection.

It belongs to a group that includes the CustomError, CustomErrorsMode, and CustomErrorsSection.

This example demonstrates how to specify values declaratively for the error elements of the customErrors section, which can also be accessed as elements of the CustomErrorCollection collection.

The following configuration file example shows how to specify values declaratively for the error elements.

<customErrors mode="RemoteOnly"
  defaultRedirect="customerror.htm">
    <error statusCode="404" redirect="customerror404.htm"/>
</customErrors>

The following code example demonstrates how to use the CustomErrorCollection class.

// Get the Web application configuration.
System.Configuration.Configuration configuration = 
    WebConfigurationManager.OpenWebConfiguration(
    "/aspnetTest");

// Get the section.
CustomErrorsSection customErrorsSection =
  (CustomErrorsSection)configuration.GetSection(
  "system.web/customErrors");

// Get the collection
CustomErrorCollection customErrorsCollection = 
    customErrorsSection.Errors;

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft