HttpClient POST请求https:

问题描述:

我正在开发一个WinRT应用程序,它可以登录到网页并获取一些数据。问题是我收到“HttpRequestException:发送请求时发生错误”消息。这里是代码:HttpClient POST请求https:

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); 

而且事后,在回调我创建了一个流,并写了凭据。

任何想法??我知道这个问题是只能用这个网页,也许我忘了送东西或者POST内容的格式不正确...

感谢

+0

有更多细节的'InnerException'吗? –

+0

我看到一个错误,指出它无法建立SSL/TLS安全通道 - 您正在收到什么? –

+0

确实,这是我的问题 –

最后problema是,只有Win8的地铁应用接受SSL3.1并且此网页使用SSL3.0。该解决方案使用了新版本的网页。

谢谢大家