Export (0) Print
Expand All

HttpClient.SendAsync Method (HttpRequestMessage, HttpCompletionOption)

.NET Framework 4.5

Send an HTTP request as an asynchronous operation.

Namespace:  System.Net.Http
Assembly:  System.Net.Http (in System.Net.Http.dll)

public Task<HttpResponseMessage> SendAsync(
	HttpRequestMessage request,
	HttpCompletionOption completionOption
)

Parameters

request
Type: System.Net.Http.HttpRequestMessage

The HTTP request message to send.

completionOption
Type: System.Net.Http.HttpCompletionOption

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

Return Value

Type: System.Threading.Tasks.Task<HttpResponseMessage>
Returns Task<TResult>.
The task object representing the asynchronous operation.

ExceptionCondition
ArgumentNullException

The request was null.

InvalidOperationException

The request message was already sent by the HttpClient instance.

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.

.NET Framework

Supported in: 4.6, 4.5

Supported in: Windows Phone 8.1
Show:
© 2015 Microsoft