Send an HTTP request as an asynchronous operation.
OverloadsThis operation doesn't block.
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>
Public Function SendAsync (request As HttpRequestMessage, completionOption As HttpCompletionOption, cancellationToken As CancellationToken) As Task(Of HttpResponseMessage)
Parameters
When the operation should complete (as soon as a response is available or after reading the whole response content).
ReturnsThe task object representing the asynchronous operation.
ExceptionsThe request message was already sent by the HttpClient instance.
The request failed due to an issue getting a valid HTTP response, such as network connectivity failure, DNS failure, server certificate validation error, or invalid server response. On .NET 8 and later versions, the reason is indicated by HttpRequestError
-or-
.NET Framework only: the request timed out.
The cancellation token was canceled. This exception is stored into the returned task.
-or-
.NET Core and .NET 5 and later only: The request failed due to timeout.
RemarksThis operation doesn't 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.
This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by Send(HttpRequestMessage, HttpCompletionOption).
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.
ExceptionsThe request message was already sent by the HttpClient instance.
The request failed due to an issue getting a valid HTTP response, such as network connectivity failure, DNS failure, server certificate validation error, or invalid server response. On .NET 8 and later versions, the reason is indicated by HttpRequestError
-or-
.NET Framework only: The request timed out.
.NET Core and .NET 5 and later only: The request failed due to timeout.
RemarksThis operation doesn't block. The returned Task<TResult> object will complete once the entire response including content is read. The behavior is the same as if ResponseContentRead has been explicitly specified.
This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by Send(HttpRequestMessage).
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
When the operation should complete (as soon as a response is available or after reading the whole response content).
ReturnsThe task object representing the asynchronous operation.
ExceptionsThe request message was already sent by the HttpClient instance.
The request failed due to an issue getting a valid HTTP response, such as network connectivity failure, DNS failure, server certificate validation error, or invalid server response. On .NET 8 and later versions, the reason is indicated by HttpRequestError
-or-
.NET Framework only: The request timed out.
.NET Core and .NET 5 and later only: The request failed due to timeout.
RemarksThis operation doesn't 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.
This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by Send(HttpRequestMessage, HttpCompletionOption).
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>
Public Overrides Function SendAsync (request As HttpRequestMessage, cancellationToken As CancellationToken) As Task(Of HttpResponseMessage)
Parameters Returns
The task object representing the asynchronous operation.
ExceptionsThe request message was already sent by the HttpClient instance.
The request failed due to an issue getting a valid HTTP response, such as network connectivity failure, DNS failure, server certificate validation error, or invalid server response. On .NET 8 and later versions, the reason is indicated by HttpRequestError
-or-
.NET Framework only: The request timed out.
The cancellation token was canceled. This exception is stored into the returned task.
-or-
.NET Core and .NET 5 and later only: The request failed due to timeout.
RemarksThis operation doesn't block. The returned Task<TResult> object will complete once the entire response including content is read. The behavior is the same as if ResponseContentRead has been explicitly specified.
This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by Send(HttpRequestMessage).
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide. In this articleWas this page helpful?
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4