Freigeben über


IExceptionHandler.TryHandleAsync Methode

Definition

Versucht, die angegebene Ausnahme asynchron innerhalb der ASP.NET Core-Pipeline zu behandeln. Implementierungen dieser Methode können benutzerdefinierte Ausnahmebehandlungslogik für verschiedene Szenarien bereitstellen.

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)

Parameter

httpContext
HttpContext

Das HttpContext-Objekt für die Anforderung.

exception
Exception

Die nicht behandelte Ausnahme.

cancellationToken
CancellationToken

Das Abbruchtoken.

Gibt zurück

Eine Aufgabe, die den asynchronen Lesevorgang darstellt. Der Wert der - Result Eigenschaft enthält das Ergebnis des Verarbeitungsvorgangs. true , wenn die Ausnahme erfolgreich behandelt wurde; andernfalls false.

Gilt für: