Home > other >  Timeout for help with HttpWebRequest access WeChat login interface
Timeout for help with HttpWebRequest access WeChat login interface

Time:10-08

Code no problem under the Windows 7, how debugging are under win10 timeout, below is the code:

HttpWebRequest myRequest=null;
MyRequest=(HttpWebRequest) WebRequest. Create (url. The ToString ());
ServicePointManager. SecurityProtocol=SecurityProtocolType. Tls12;//WeChat USES is TLS12
If (url. StartsWith (" HTTPS, "StringComparison. OrdinalIgnoreCase))
{
ServicePointManager. ServerCertificateValidationCallback=
New RemoteCertificateValidationCallback (CheckValidationResult);
}
//myRequest. ServicePoint. Expect100Continue=true;
//myRequest. AllowAutoRedirect=false;
MyRequest. Method=Method;
MyRequest. ProtocolVersion=HttpVersion. Version10;
If (timeout)
MyRequest. Timeout=7000;
MyRequest. KeepAlive=true;
MyRequest. CookieContainer=backcookie;
MyRequest. Headers. The Add (" Cookie ", cookiesstr);
MyRequest. UserAgent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10 _11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36 ";
MyRequest. ContentType=(method=="POST"? "Application/json; Charset=utf-8 ":" application/x - WWW - form - urlencoded ");
If (method!="GET")
{
Byte [] data=https://bbs.csdn.net/topics/Encoding.UTF8.GetBytes (paramPost);
MyRequest. ContentLength=data. Length;
Using (Stream dataStream=myRequest. GetRequestStream ())
{
DataStream. Write (data, 0, the data Length);
DataStream. Close ();
}
}
HttpWebResponse myResponse=(HttpWebResponse) myRequest. The method GetResponse ();//card here, error timeout

CodePudding user response:

WeChat url can normal visit?

CodePudding user response:

Web pages can be accessed, and the program (HttpWebResponse) request. The method GetResponse (); Here will timeout, the other no problem running under Windows 7, win10 will timeout

CodePudding user response:

HTTPS instead of HTTP problem solving and no matter so much, so first
  • Related