HttpClient.SendAsync HttpClient.SendAsync HttpClient.SendAsync HttpClient.SendAsync Method

Definition

Send an HTTP request as an asynchronous operation.

Overloads

SendAsync(HttpRequestMessage, HttpCompletionOption, CancellationToken) SendAsync(HttpRequestMessage, HttpCompletionOption, CancellationToken) SendAsync(HttpRequestMessage, HttpCompletionOption, CancellationToken)

Send an HTTP request as an asynchronous operation.

SendAsync(HttpRequestMessage) SendAsync(HttpRequestMessage) SendAsync(HttpRequestMessage) SendAsync(HttpRequestMessage)

Send an HTTP request as an asynchronous operation.

SendAsync(HttpRequestMessage, HttpCompletionOption) SendAsync(HttpRequestMessage, HttpCompletionOption) SendAsync(HttpRequestMessage, HttpCompletionOption) SendAsync(HttpRequestMessage, HttpCompletionOption)

Send an HTTP request as an asynchronous operation.

SendAsync(HttpRequestMessage, CancellationToken) SendAsync(HttpRequestMessage, CancellationToken) SendAsync(HttpRequestMessage, CancellationToken)

Send an HTTP request as an asynchronous operation.

Remarks

This operation will not block.

SendAsync(HttpRequestMessage, HttpCompletionOption, CancellationToken) SendAsync(HttpRequestMessage, HttpCompletionOption, CancellationToken) SendAsync(HttpRequestMessage, HttpCompletionOption, CancellationToken)

Send an HTTP request as an asynchronous operation.

public:
 System::Threading::Tasks::Task<System::Net::Http::HttpResponseMessage ^> ^ SendAsync(System::Net::Http::HttpRequestMessage ^ request, System::Net::Http::HttpCompletionOption completionOption, System::Threading::CancellationToken cancellationToken);
public System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> SendAsync (System.Net.Http.HttpRequestMessage request, System.Net.Http.HttpCompletionOption completionOption, System.Threading.CancellationToken cancellationToken);
override this.SendAsync : System.Net.Http.HttpRequestMessage * System.Net.Http.HttpCompletionOption * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>

Parameters

completionOption
HttpCompletionOption HttpCompletionOption HttpCompletionOption HttpCompletionOption

When the operation should complete (as soon as a response is available or after reading the whole response content).

cancellationToken
CancellationToken CancellationToken CancellationToken CancellationToken

The cancellation token to cancel operation.

Returns

The task object representing the asynchronous operation.

Exceptions

The request failed due to an underlying issue such as network connectivity, DNS failure, server certificate validation or timeout.

Remarks

This operation will not block. Depending on the value of the completionOption parameter, the returned Task<TResult> object will complete as soon as a response is available or the entire response including content is read.

SendAsync(HttpRequestMessage) SendAsync(HttpRequestMessage) SendAsync(HttpRequestMessage) SendAsync(HttpRequestMessage)

Send an HTTP request as an asynchronous operation.

public:
 System::Threading::Tasks::Task<System::Net::Http::HttpResponseMessage ^> ^ SendAsync(System::Net::Http::HttpRequestMessage ^ request);
public System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> SendAsync (System.Net.Http.HttpRequestMessage request);
override this.SendAsync : System.Net.Http.HttpRequestMessage -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>
Public Function SendAsync (request As HttpRequestMessage) As Task(Of HttpResponseMessage)

Parameters

Returns

The task object representing the asynchronous operation.

Exceptions

The request failed due to an underlying issue such as network connectivity, DNS failure, server certificate validation or timeout.

Remarks

This operation will not block. The returned Task<TResult> object will complete once the entire response including content is read.

SendAsync(HttpRequestMessage, HttpCompletionOption) SendAsync(HttpRequestMessage, HttpCompletionOption) SendAsync(HttpRequestMessage, HttpCompletionOption) SendAsync(HttpRequestMessage, HttpCompletionOption)

Send an HTTP request as an asynchronous operation.

public:
 System::Threading::Tasks::Task<System::Net::Http::HttpResponseMessage ^> ^ SendAsync(System::Net::Http::HttpRequestMessage ^ request, System::Net::Http::HttpCompletionOption completionOption);
public System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> SendAsync (System.Net.Http.HttpRequestMessage request, System.Net.Http.HttpCompletionOption completionOption);
override this.SendAsync : System.Net.Http.HttpRequestMessage * System.Net.Http.HttpCompletionOption -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>
Public Function SendAsync (request As HttpRequestMessage, completionOption As HttpCompletionOption) As Task(Of HttpResponseMessage)

Parameters

completionOption
HttpCompletionOption HttpCompletionOption HttpCompletionOption HttpCompletionOption

When the operation should complete (as soon as a response is available or after reading the whole response content).

Returns

The task object representing the asynchronous operation.

Exceptions

The request failed due to an underlying issue such as network connectivity, DNS failure, server certificate validation or timeout.

Remarks

This operation will not block. Depending on the value of the completionOption parameter, the returned Task<TResult> object will complete as soon as a response is available or the entire response including content is read.

SendAsync(HttpRequestMessage, CancellationToken) SendAsync(HttpRequestMessage, CancellationToken) SendAsync(HttpRequestMessage, CancellationToken)

Send an HTTP request as an asynchronous operation.

public:
 override System::Threading::Tasks::Task<System::Net::Http::HttpResponseMessage ^> ^ SendAsync(System::Net::Http::HttpRequestMessage ^ request, System::Threading::CancellationToken cancellationToken);
public override System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken);
override this.SendAsync : System.Net.Http.HttpRequestMessage * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>

Parameters

cancellationToken
CancellationToken CancellationToken CancellationToken CancellationToken

The cancellation token to cancel operation.

Returns

The task object representing the asynchronous operation.

Exceptions

The request failed due to an underlying issue such as network connectivity, DNS failure, server certificate validation or timeout.

Remarks

This operation will not block. The returned Task<TResult> object will complete once the entire response including content is read.

Applies to