HttpClientHandler.Send(HttpRequestMessage, CancellationToken) Method

Definition

Creates an instance of HttpResponseMessage based on the information provided in the HttpRequestMessage.

C#
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
protected internal override System.Net.Http.HttpResponseMessage Send(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken);
C#
protected internal override System.Net.Http.HttpResponseMessage Send(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken);

Parameters

request
HttpRequestMessage

The HTTP request message.

cancellationToken
CancellationToken

A cancellation token to cancel the operation.

Returns

The HTTP response message.

Attributes

Exceptions

The request was null.

For HTTP/2 and higher or when requesting version upgrade is enabled by RequestVersionOrHigher.

-or-

If using custom class derived from HttpContent not overriding SerializeToStream(Stream, TransportContext, CancellationToken) method.

-or-

If using custom HttpMessageHandler not overriding Send(HttpRequestMessage, CancellationToken) method.

The request was canceled.

-or-

If the OperationCanceledException exception nests the TimeoutException: The request failed due to timeout.

This exception is stored into the returned task.

Applies to

Product Versions
.NET 5, 6, 7, 8, 9, 10