CustomErrorCollection.Add(CustomError) メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
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必要があります。
適用対象
GitHub で Microsoft と共同作業する
このコンテンツのソースは GitHub にあります。そこで、issue や pull request を作成および確認することもできます。 詳細については、共同作成者ガイドを参照してください。
.NET