简体   繁体   中英

POST request in WP8 app

I'm creating a VB.NET app for Windows Phone 8 and I'm currently looking for a solution to send a POST request to a page, and to get the response (simply knowing the page content). I searched on several forums but none of them helped me.

Thank you in advance

Before u have to download this NuGet package HttpClient for Windows Phone and try this code: var httpClient = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "http://www.google.com/"); var response = await httpClient.SendAsync(request); var result = response.Content.ReadAsStringAsync().Result;

This will help you.

And u have to use in async method try this. Async Function AccessTheWebAsync() As Task(Of Integer) Dim client As HttpClient = New HttpClient() Dim getStringTask As Task(Of String) = client.GetStringAsync("http://google.com") Dim urlContents As String = Await getStringTask Return urlContents.Length End Function

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM