次の方法で共有


CustomErrorCollection.Set(CustomError) メソッド

定義

指定された CustomError をコレクションに追加します。

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)

パラメーター

customError
CustomError

コレクションに追加する CustomError

次のコード例は、指定した CustomError オブジェクトを設定する方法を示しています。 コレクションを取得する方法については、クラス トピックの CustomErrorCollection コード例を参照してください。

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

注釈

この指定されたエラーは、現在の構成エラー要素を置き換えます。

適用対象