Client. Try Get Buffer Async(Uri) Method
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.
public: virtual IAsyncOperationWithProgress<HttpGetBufferResult ^, HttpProgress> ^ TryGetBufferAsync(Uri ^ uri) = TryGetBufferAsync;
/// [Windows.Foundation.Metadata.RemoteAsync] IAsyncOperationWithProgress<HttpGetBufferResult, HttpProgress> TryGetBufferAsync(Uri const& uri);
[Windows.Foundation.Metadata.RemoteAsync] public IAsyncOperationWithProgress<HttpGetBufferResult,HttpProgress> TryGetBufferAsync(System.Uri uri);
Public Function TryGetBufferAsync (uri As Uri) As IAsyncOperationWithProgress(Of HttpGetBufferResult, HttpProgress)
The object representing the asynchronous operation.
Windows 10, version 1903 (introduced in 10.0.18362.0)
Windows.Foundation.UniversalApiContract (introduced in v8.0)
This method is commonly called when downloading binary content such as small images and compressed files. Very large binary content should be downloaded as a stream with HttpClient.TryGetInputStreamAsync to prevent unneeded buffering.
The HttpClient class is often used by an app to download and then parse text. It is possible that the character encoding specified in the Content-Type header by an HTTP server does not match the character encoding of the HTTP response body (the XML encoding in an XML document, for example). One way to use HttpClient with text is to call the TryGetStringAsync method and pass the returned string to the text parser. However, this can result in errors if the Content-Type is not a type expressible as a string. A reliable way to use HttpClient with an XML parser is to call the TryGetBufferAsync method and parse the buffer for the "<?xml>" element. Then use the character encoding specified ("<xmlversion="1.0" encoding="UTF-8"?>", for example) to parse the HTTP response body. For other text formats, similar methods can be used where the app scans the initial part of the HTTP response body to determine the character encoding used.
Submit and view feedback for