CustomErrorCollection.Add(CustomError) Metodo

Definizione

Aggiunge un CustomError oggetto all'insieme.

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)

Parametri

customError
CustomError

L'oggetto CustomError da aggiungere esiste già nell'insieme o l'insieme è di sola lettura.

Esempio

Nell'esempio di codice seguente viene aggiunto un CustomError oggetto all'insieme CustomErrorCollection .

Fare riferimento all'esempio di codice nell'argomento della CustomErrorCollection classe per informazioni su come ottenere la raccolta.

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

Commenti

Prima di aggiungere un errore personalizzato alla raccolta, è necessario creare un CustomError oggetto error e inizializzare le Redirect proprietà e StatusCode .

Si applica a