共用方式為


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

備註

這個指定的錯誤會取代目前的組態錯誤專案。

適用於