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

注解

此指定错误替换当前配置错误元素。

适用于