Sdílet prostřednictvím


CustomErrorCollection.Add(CustomError) Metoda

Definice

CustomError Přidá objekt do kolekce.

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)

Parametry

customError
CustomError

Objekt CustomError , který chcete přidat, již v kolekci existuje nebo kolekce je jen pro čtení.

Příklady

Následující příklad kódu přidá CustomError objekt do CustomErrorCollection kolekce.

V příkladu kódu v tématu předmětu CustomErrorCollection se dozvíte, jak získat kolekci.

// 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

Poznámky

Před přidáním vlastní chyby do kolekce musíte vytvořit CustomError objekt chyby a inicializovat Redirect a StatusCode vlastnosti.

Platí pro