CustomErrorCollection.Set Method (CustomError)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Use BaseTrue

Adds the specified CustomError to the collection.

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

public void Set(
	CustomError customError
)

Parameters

customError
Type: System.Web.Configuration.CustomError

The CustomError to add to the collection.

This specified error replaces the current configuration error element.

The following code example shows how to set the specified CustomError object. Refer to the code example in the CustomErrorCollection class topic to learn how to get the collection.

// Using the Set method.
CustomError newCustomError =
new CustomError(404, "customerror404.htm");

// Update the configuration file.
if (!customErrorsSection.SectionInformation.IsLocked)
{
    // Add the new custom error to the collection.
    customErrorsCollection.Set(newCustomError);
    configuration.Save();
}

.NET Framework
Available since 2.0
Return to top
Show: