次の方法で共有


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作成し、 プロパティと StatusCode プロパティを初期化するRedirect必要があります。

適用対象