CustomErrorCollection.Remove(String) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
從集合中移除一個 CustomError 物件。
public:
void Remove(System::String ^ statusCode);
public void Remove(string statusCode);
member this.Remove : string -> unit
Public Sub Remove (statusCode As String)
參數
- statusCode
- String
與自訂錯誤相關聯的 HTTP 狀態碼。
範例
以下程式碼範例說明如何移除 CustomError 指定狀態碼的物件。 參考課堂主題中的 CustomErrorCollection 程式碼範例,學習如何取得該集合。
// Using the Remove method.
if (!customErrorsSection.SectionInformation.IsLocked)
{
// Remove the error with statuscode 404.
customErrorsCollection.Remove("404");
configuration.Save();
}
' Using the Remove method.
If Not customErrorsSection.SectionInformation.IsLocked Then
' Remove the error with statuscode 404.
customErrorsCollection.Remove("404")
configuration.Save()
End If
備註
此 Remove 方法會在配置檔的當前階層層級插入一個 remove 元素 customErrors 。 這會移除階層 add 結構中父組態檔案中定義元素的參考。
Note
add這些元素不會從父組態檔案中刪除。 這個 remove 元素只是讓它們失效。 然而,這個 Remove 方法實際上會在目前的階層層級刪除它們。