What makes this HTTPS WebRequest time out even though it works in the browser?

前端 未结 6 1325
挽巷
挽巷 2020-12-04 23:05

Here\'s my request:

var request = (HttpWebRequest) WebRequest.Create(\"https://mtgox.com/\");
request.CookieContainer = new CookieContainer();
request.AllowA         


        
6条回答
  •  佛祖请我去吃肉
    2020-12-04 23:10

    I had the same timeout issue with https requests and none of the answers helped me. Just now I found a solution that resolved the problem for me. Note that this works only with .net framework 4.5 or higher.

    System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
    var response = WebRequest.Create("https://yoursecurewebservice").GetResponse();
    var body = new StreamReader(response.GetResponseStream()).ReadToEnd();
    Console.WriteLine(body);
    

提交回复
热议问题