This code works on windows forms :
string URI = "http://localhost/1/index.php?dsa=232323";
string myParameters = "";
using (WebClient wc = new WebClient())
{
wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
string HtmlResult = wc.UploadString(URI, myParameters);
}
But i want to send http GET request from windows phone 8 . in wp 8 there are no methods UploadString() and etc...
Simply use HttpClient
using(HttpClient hc = new HttpClient())
{
var response = await hc.PostAsync(url,new StringContent (yourString));
}
And for your case, you can upload FormUrlEncodedContent content instead of forming upload string manually.
using(HttpClient hc = new HttpClient())
{
var keyValuePairs = new Dictionary<string,string>();
// Fill keyValuePairs
var content = new FormUrlEncodedContent(keyValuePairs);
var response = await hc.PostAsync(url, content);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With