CustomErrorCollection.Add(CustomError) メソッド

定義

CustomError オブジェクトをコレクションに追加します。

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)

パラメーター

customError
CustomError

追加する CustomError オブジェクトが既にコレクションに存在するか、コレクションが読み取り専用です。

次のコード例では、CustomError コレクションにCustomErrorCollection オブジェクトを追加します。

コレクションを取得する方法については、 CustomErrorCollection クラスのトピックのコード例を参照してください。

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

注釈

カスタム エラーをコレクションに追加する前に、 CustomError エラー オブジェクトを作成し、 Redirect プロパティと StatusCode プロパティを初期化する必要があります。

適用対象