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 만들고 및 Redirect 속성을 초기화 StatusCode 해야 합니다.

적용 대상