Ask Learn
Preview
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Send an HTTP request as an asynchronous operation.
SendAsync(HttpRequestMessage, HttpCompletionOption, CancellationToken) |
Send an HTTP request as an asynchronous operation. |
SendAsync(HttpRequestMessage) |
Send an HTTP request as an asynchronous operation. |
SendAsync(HttpRequestMessage, HttpCompletionOption) |
Send an HTTP request as an asynchronous operation. |
SendAsync(HttpRequestMessage, CancellationToken) |
Send an HTTP request as an asynchronous operation. |
This operation doesn't block.
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)
The HTTP request message to send.
When the operation should complete (as soon as a response is available or after reading the whole response content).
The cancellation token to cancel operation.
The task object representing the asynchronous operation.
The request
is null
.
The 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.
This 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.
Note
In case of timeout, different exceptions are thrown on different .NET implementations.
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).
Product | Versions |
---|---|
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)
The HTTP request message to send.
The task object representing the asynchronous operation.
The request
is null
.
The 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.
This 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.
Note
In case of timeout, different exceptions are thrown on different .NET implementations.
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).
Product | Versions |
---|---|
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)
The HTTP request message to send.
When the operation should complete (as soon as a response is available or after reading the whole response content).
The task object representing the asynchronous operation.
The request
is null
.
The 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.
This 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.
Note
In case of timeout, different exceptions are thrown on different .NET implementations.
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).
Product | Versions |
---|---|
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)
The HTTP request message to send.
The cancellation token to cancel operation.
The task object representing the asynchronous operation.
The request
is null
.
The 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.
This 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.
Note
In case of timeout, different exceptions are thrown on different .NET implementations.
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).
Product | Versions |
---|---|
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign in