Aracılığıyla paylaş


CustomErrorCollection.Add(CustomError) Yöntem

Tanım

Koleksiyona bir CustomError nesne ekler.

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)

Parametreler

customError
CustomError

CustomError Eklenecek nesne koleksiyonda zaten var veya koleksiyon salt okunur.

Örnekler

Aşağıdaki kod örneği koleksiyona CustomErrorCollection bir CustomError nesnesi ekler.

Koleksiyonu nasıl edineceğinizi öğrenmek için sınıf konusunun CustomErrorCollection kod örneğine bakın.

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

Açıklamalar

Koleksiyona özel bir hata eklemeden önce bir CustomError hata nesnesi oluşturmanız ve ve StatusCode özelliklerini başlatmanız Redirect gerekir.

Şunlara uygulanır