CustomError.StatusCode Property

Definition

Gets or sets the HTTP error status code.

C#
[System.Configuration.ConfigurationProperty("statusCode", IsKey=true, IsRequired=true)]
[System.Configuration.IntegerValidator(MaxValue=999, MinValue=100)]
public int StatusCode { get; set; }

Property Value

The HTTP error status code that causes the redirection to the custom error page.

Attributes

Examples

The following code example shows how to use the status code. Refer to the code example in the CustomError class topic to learn how to get the collection.

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

// Set the second error StatusCode.
currentError1.StatusCode = 404;

Remarks

The HTTP status code is used by the ASP.NET infrastructure to redirect the application to the error page when a specific error occurs.

Note

The custom error is issued only if it is caused by an entity handled by ASP.NET; otherwise, a standard error is issued.

Applies to

Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1