HttpClient.TrySendRequestAsync Method
Definition
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.
Overloads
TrySendRequestAsync(HttpRequestMessage) |
Sends an HTTP request to the specified Uri as an asynchronous operation. For programming guidance for the HttpClient class, and code examples, see the HttpClient conceptual topic. |
TrySendRequestAsync(HttpRequestMessage, HttpCompletionOption) |
Sends an HTTP request with a completion option to the specified Uri as an asynchronous operation. For programming guidance for the HttpClient class, and code examples, see the HttpClient conceptual topic. |
TrySendRequestAsync(HttpRequestMessage)
Sends an HTTP request to the specified Uri as an asynchronous operation. For programming guidance for the HttpClient class, and code examples, see the HttpClient conceptual topic.
public:
virtual IAsyncOperationWithProgress<HttpRequestResult ^, HttpProgress> ^ TrySendRequestAsync(HttpRequestMessage ^ request) = TrySendRequestAsync;
/// [Windows.Foundation.Metadata.Overload("TrySendRequestAsync")]
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncOperationWithProgress<HttpRequestResult, HttpProgress> TrySendRequestAsync(HttpRequestMessage const& request);
[Windows.Foundation.Metadata.Overload("TrySendRequestAsync")]
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncOperationWithProgress<HttpRequestResult,HttpProgress> TrySendRequestAsync(HttpRequestMessage request);
function trySendRequestAsync(request)
Public Function TrySendRequestAsync (request As HttpRequestMessage) As IAsyncOperationWithProgress(Of HttpRequestResult, HttpProgress)
Parameters
- request
- HttpRequestMessage
The HTTP request message to send.
Returns
The object representing the asynchronous operation.
- Attributes
Windows requirements
Device family |
Windows 10, version 1903 (introduced in 10.0.18362.0)
|
API contract |
Windows.Foundation.UniversalApiContract (introduced in v8.0)
|
Remarks
This operation will not throw an exception on network errors. Instead you should examine the HttpRequestResult to learn about the original HTTP request, the resulting HTTP response (if any) and error (if any). This operation will throw when the operation is canceled.
This operation will not block. The returned IAsyncOperationWithProgress (of HttpRequestResult and HttpProgress) completes after the whole response (including content) is read.
See also
Applies to
TrySendRequestAsync(HttpRequestMessage, HttpCompletionOption)
Sends an HTTP request with a completion option to the specified Uri as an asynchronous operation. For programming guidance for the HttpClient class, and code examples, see the HttpClient conceptual topic.
public:
virtual IAsyncOperationWithProgress<HttpRequestResult ^, HttpProgress> ^ TrySendRequestAsync(HttpRequestMessage ^ request, HttpCompletionOption completionOption) = TrySendRequestAsync;
/// [Windows.Foundation.Metadata.Overload("TrySendRequestAsync2")]
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncOperationWithProgress<HttpRequestResult, HttpProgress> TrySendRequestAsync(HttpRequestMessage const& request, HttpCompletionOption const& completionOption);
[Windows.Foundation.Metadata.Overload("TrySendRequestAsync2")]
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncOperationWithProgress<HttpRequestResult,HttpProgress> TrySendRequestAsync(HttpRequestMessage request, HttpCompletionOption completionOption);
function trySendRequestAsync(request, completionOption)
Public Function TrySendRequestAsync (request As HttpRequestMessage, completionOption As HttpCompletionOption) As IAsyncOperationWithProgress(Of HttpRequestResult, HttpProgress)
Parameters
- request
- HttpRequestMessage
The HTTP request message to send.
- completionOption
- HttpCompletionOption
A value that indicates whether the HttpClient operation is considered completed when all of the response is read, or when just the headers are read.
Returns
The object representing the asynchronous operation.
- Attributes
Windows requirements
Device family |
Windows 10, version 1903 (introduced in 10.0.18362.0)
|
API contract |
Windows.Foundation.UniversalApiContract (introduced in v8.0)
|
Remarks
This operation will not throw an exception on network errors. Instead you should examine the HttpRequestResult to learn about the original HTTP request, the resulting HTTP response (if any) and error (if any). This operation will throw when the operation is canceled.
This operation will not block. The returned IAsyncOperationWithProgress (of HttpRequestResult and HttpProgress) completes based on the completionOption parameter after part or all of the response (including content) is read.
See also
- HttpRequestMessage
- HttpRequestResult
- HttpCompletionOption
- HttpProgress
- HttpResponseMessage
- HttpClient