CustomErrorCollection.Get Method

Definition

Gets the specified CustomError.

Overloads

Get(String)

Gets the CustomError object with the specified status code.

Get(Int32)

Gets the CustomError object with the specified index.

Get(String)

Gets the CustomError object with the specified status code.

public System.Web.Configuration.CustomError Get (string statusCode);

Parameters

statusCode
String

The HTTP status code associated with the custom error.

Returns

The CustomError object with the specified status code.

Examples

The following code example shows how to get a CustomError object with the specified status code.

Refer to the code example in the CustomErrorCollection class topic to learn how to get the collection.

// Get the error with status code 404.
CustomError customError1 = 
    customErrorsCollection["404"];

Applies to

.NET Framework 4.8.1 and other versions
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

Get(Int32)

Gets the CustomError object with the specified index.

public System.Web.Configuration.CustomError Get (int index);

Parameters

index
Int32

The collection index of the CustomError object.

Returns

The CustomError with the specified index.

Examples

The following code example shows how to get a CustomError object at the specified collection index.

Refer to the code example in the CustomErrorCollection class topic to learn how to get the collection.

// Get the error with collection index 0.
CustomError customError = 
    customErrorsCollection[0];

Applies to

.NET Framework 4.8.1 and other versions
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