Share via


CustomErrorCollection.Set(CustomError) Méthode

Définition

Ajoute l'objet CustomError spécifié à la collection.

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

Paramètres

customError
CustomError

Objet CustomError à ajouter à la collection.

Exemples

L’exemple de code suivant montre comment définir l’objet spécifié CustomError . Reportez-vous à l’exemple de code de la CustomErrorCollection rubrique de classe pour savoir comment obtenir la 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();
}
' Using the Set method.
  Dim newCustomError _
  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.Set(newCustomError)
   configuration.Save()
End If

Remarques

Cette erreur spécifiée remplace l’élément d’erreur de configuration actuel.

S’applique à