Share via


CustomError.StatusCode 屬性

定義

取得或設定 HTTP 錯誤狀態碼。

public:
 property int StatusCode { int get(); void set(int value); };
[System.Configuration.ConfigurationProperty("statusCode", IsKey=true, IsRequired=true)]
[System.Configuration.IntegerValidator(MaxValue=999, MinValue=100)]
public int StatusCode { get; set; }
[<System.Configuration.ConfigurationProperty("statusCode", IsKey=true, IsRequired=true)>]
[<System.Configuration.IntegerValidator(MaxValue=999, MinValue=100)>]
member this.StatusCode : int with get, set
Public Property StatusCode As Integer

屬性值

Int32

造成重新導向到自訂錯誤頁面的 HTTP 錯誤狀態碼。

屬性

範例

下列程式碼範例示範如何使用狀態碼。 請參閱類別主題中的 CustomError 程式碼範例,以瞭解如何取得集合。

// Get second error StatusCode.
CustomError currentError1 =
    customErrorsCollection[1];
int currentStatusCode =
    currentError1.StatusCode;

// Set the second error StatusCode.
currentError1.StatusCode = 404;
' Get second error StatusCode.
  Dim currentError1 As CustomError = _
  customErrorsCollection(1)
  Dim currentStatusCode As Integer = _
  currentError1.StatusCode

' Set the second error StatusCode.
  currentError1.StatusCode = 404

備註

當發生特定錯誤時,ASP.NET 基礎結構會使用 HTTP 狀態碼,將應用程式重新導向至錯誤頁面。

注意

只有在由 ASP.NET 處理的實體所造成時,才會發出自訂錯誤,否則會發出標準錯誤。

適用於