CustomErrorCollection.Set(CustomError) Metod

Definition

Lägger till den angivna CustomError i samlingen.

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)

Parametrar

customError
CustomError

Att CustomError lägga till i samlingen.

Exempel

I följande kodexempel visas hur du anger det angivna CustomError objektet. Se kodexemplet i klassavsnittet CustomErrorCollection för att lära dig hur du hämtar samlingen.

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

Kommentarer

Det angivna felet ersätter det aktuella konfigurationsfelelementet.

Gäller för