I'm a bit puzzled and could do with some help. I have the following code for calling a webservice using the BCL.Async - UploadStringTaskAsync , the code below works fine when its in the xaml.cs class but when I move the code to a PhoneLibrary. it hangs on UploadStringTaskAsyncline and never timeout or returns anything. Any thoughts what going wrong.
xaml.cs
var http = new WebClient();
string postdata = "cmd=GWRLogin&data=%3cgip%3e%3cversion%3e1%3c%2fversion%3e%3cemail%3e???%40???????%3c%2femail%3e%3cpassword%3e3ec66b1?????156869af23318771f44aeb7f97780a88aa0e135c3f84%3c%2fpassword%3e%3c%2fgip%3e";
http.Encoding = System.Text.Encoding.GetEncoding("ISO-8859-1");
http.Headers[HttpRequestHeader.KeepAlive] = "true";
http.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
http.Headers[HttpRequestHeader.ContentLength] = postdata.Length.ToString();
var Token = await http.UploadStringTaskAsync("https://eon.?????.eu/???/???.php", "POST", postdata);
Textblock.Text = Token;
Dll and call
private void Button_Click(object sender, RoutedEventArgs e)
{
Greenwave gw = new Greenwave();
ResultBlock.Text = gw.Login().Result;
}
public class Greenwave
{
public async Task<string> Login()
{
var http = new WebClient();
string postdata = "cmd=GWRLogin&data=%3cgip%3e%3cversion%3e1%3c%2fversion%3e%3cemail%3e???%40???????%3c%2femail%3e%3cpassword%3e3ec66b1?????156869af23318771f44aeb7f97780a88aa0e135c3f84%3c%2fpassword%3e%3c%2fgip%3e";
http.Encoding = System.Text.Encoding.GetEncoding("ISO-8859-1");
http.Headers[HttpRequestHeader.KeepAlive] = "true";
http.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
http.Headers[HttpRequestHeader.ContentLength] = postdata.Length.ToString();
return await http.UploadStringTaskAsync("https://eon.?????.eu/???/???.php", "POST", postdata);
}
}
Regards
Kevin