HttpHelper
Warning
(This API is obsolete and has been removed. Please use System.Net.Http.HttpClient or Windows.Web.Http.HttpClient directly)
The HttpHelper (/dotnet/api/microsoft.toolkit.uwp.httphelper
) represents an HTTP request message including headers.
Syntax
var request = new HttpHelperRequest(new Uri("URI"), HttpMethod.Post);
var response = await HttpHelper.Instance.SendRequestAsync(request);
Private request = New HttpHelperRequest(New Uri("URI"), HttpMethod.Post)
Private response = Await HttpHelper.Instance.SendRequestAsync(request)
Properties
The HttpHelper class has these properties.
Property | Type | Description |
---|---|---|
Instance ![]() |
HttpHelper | Gets the instance of HTTPHelper exposed as singleton. |
Methods
The HttpHelper class has these methods. It also inherits from Object class.
Methods | Return Type | Description |
---|---|---|
GetInputStreamAsync(HttpHelperRequest, CancellationToken) | Task<HttpHelperResponse> | Process Http Request using instance of HttpClient |
SendRequestAsync(HttpHelperRequest, CancellationToken) | Task<HttpHelperResponse> | Takes an instance of HttpHelperRequest as a parameter and passes it to server. It turns server response as HttpHelperResponse |
ToString() | string | Returns a string that represents the current HttpHelper object |
Remarks
The HttpHelper class exposes an instance of the class as a static property. It additionally has one method - SendRequestAsync. This method requires an instance of HttpHelperRequest as an input parameter and returns an instance of HttpHelperResponse
Example
using (var request = new HttpHelperRequest(new Uri(twitterUrl), HttpMethod.Post))
{
using (var response = await HttpHelper.Instance.SendRequestAsync(request))
{
return await response.GetTextResultAsync();
}
}
Using request = New HttpHelperRequest(New Uri(twitterUrl), HttpMethod.Post)
Using response = Await HttpHelper.Instance.SendRequestAsync(request)
Return Await response.GetTextResultAsync()
End Using
End Using
Requirements
Device family | Universal, 10.0.16299.0 or higher |
---|---|
Namespace | Microsoft.Toolkit.Uwp |
NuGet package | Microsoft.Toolkit.Uwp |
API
- HttpHelper source code (
https://github.com/windows-toolkit/WindowsCommunityToolkit/blob/rel/7.1.0/Microsoft.Toolkit.Uwp/Helpers/HttpHelper/HttpHelper.cs
)