CustomErrorCollection.Add(CustomError) Methode

Definitie

Hiermee voegt u een CustomError object toe aan de verzameling.

public:
 void Add(System::Web::Configuration::CustomError ^ customError);
public void Add(System.Web.Configuration.CustomError customError);
member this.Add : System.Web.Configuration.CustomError -> unit
Public Sub Add (customError As CustomError)

Parameters

customError
CustomError

Het CustomError object dat moet worden toegevoegd, bestaat al in de verzameling of de verzameling is alleen-lezen.

Voorbeelden

In het volgende codevoorbeeld wordt een CustomError object aan de CustomErrorCollection verzameling toegevoegd.

Raadpleeg het codevoorbeeld in het CustomErrorCollection klasseonderwerp voor meer informatie over het ophalen van de verzameling.

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

// Update the configuration file.
if (!customErrorsSection.SectionInformation.IsLocked)
{
    // Add the new custom error to the collection.
    customErrorsCollection.Add(newCustomError2);
    configuration.Save();
}
' Using the Add method.
  Dim newCustomError2 _
  As New CustomError(404, "customerror404.htm")

' Update the configuration file.
If Not customErrorsSection.SectionInformation.IsLocked Then
   ' Add the new custom error to the collection.
   customErrorsCollection.Add(newCustomError2)
   configuration.Save()
End If

Opmerkingen

Voordat u een aangepaste fout aan de verzameling toevoegt, moet u een CustomError foutobject maken en de Redirect en StatusCode eigenschappen initialiseren.

Van toepassing op