0

我正在开发一个登录网页并获取一些数据的 WinRT 应用程序。问题是我收到“HttpRequestException:发送请求时出错”消息。这是代码:

Uri url = new Uri("https://miyoigo-b.yoigo.com/selfcare/login");
HttpContent msg = new StringContent("account[cli]=" + number + "&password=" + pass);
HttpClientHandler handler = new HttpClientHandler();
handler.UseDefaultCredentials = true;
handler.UseCookies = true;
handler.CookieContainer = new CookieContainer();

HttpClient req = new HttpClient(handler);
req.DefaultRequestHeaders.Add("Host", "miyoigo-b.yoigo.com");
req.DefaultRequestHeaders.ExpectContinue = false;
HttpResponseMessage response = await req.PostAsync(url, msg);
string responseBody = await response.Content.ReadAsStringAsync();

我一直在尝试我在互联网上找到的很多东西,甚至禁用了我的防火墙,但没有任何效果。我正在从 Windows Phone 应用程序移植它,它确实适用于:

Uri url = new Uri("https://miyoigo-b.yoigo.com/selfcare/login");
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url);
req.Method = "POST";
req.Headers["Host"] = "miyoigo-b.yoigo.com";
req.CookieContainer = new CookieContainer();
req.BeginGetRequestStream(new AsyncCallback(WriteCallback), req);

之后,在回调中,我创建了一个 Stream 并编写了凭据。

任何的想法??我知道问题出在这个网页上,可能是我忘记发送某些内容或 POST 内容的格式不正确...

谢谢

4

1 回答 1

0

最后的问题是 Win8 Metro Apps 只接受 SSL3.1 而这个网页使用的是 SSL3.0。解决方案是使用新版本的网页。

谢谢你们

于 2012-09-29T12:11:18.980 回答