Dela via


IExceptionHandler.TryHandleAsync Method

Definition

Tries to handle the specified exception asynchronously within the ASP.NET Core pipeline. Implementations of this method can provide custom exception-handling logic for different scenarios.

public System.Threading.Tasks.ValueTask<bool> TryHandleAsync (Microsoft.AspNetCore.Http.HttpContext httpContext, Exception exception, System.Threading.CancellationToken cancellationToken);
abstract member TryHandleAsync : Microsoft.AspNetCore.Http.HttpContext * Exception * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<bool>
Public Function TryHandleAsync (httpContext As HttpContext, exception As Exception, cancellationToken As CancellationToken) As ValueTask(Of Boolean)

Parameters

httpContext
HttpContext

The HttpContext for the request.

exception
Exception

The unhandled exception.

cancellationToken
CancellationToken

The cancellation token.

Returns

A task that represents the asynchronous read operation. The value of its Result property contains the result of the handling operation. true if the exception was handled successfully; otherwise false.

Applies to