求助 用HttpWebRequest访问微信登录接口超时

similing 2017-02-19 12:17:15
代码在win7下没有问题,在win10下怎么调试都是超时,下面是代码:

HttpWebRequest myRequest = null;
myRequest = (HttpWebRequest)WebRequest.Create(url.ToString());
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;//微信采用的是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.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 = Encoding.UTF8.GetBytes(paramPost);
myRequest.ContentLength = data.Length;
using (Stream dataStream = myRequest.GetRequestStream())
{
dataStream.Write(data, 0, data.Length);
dataStream.Close();
}
}
HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();//卡在这里,报错超时

访问这个链接获取uuid没有问题:https://login.weixin.qq.com/jslogin?appid=wx782c26e4c19acffb&redirect_uri=https:%2F%2Fwx.qq.com%2Fcgi-bin%2Fmmwebwx-bin%2Fwebwxnewloginpage&fun=new&lang=en_US&_=1452859503801
但从访问https://login.weixin.qq.com/qrcode/ uuid 开始就超时
包括后面的判断是否扫码都超时,实在不知道是什么原因了,求帮忙T.T
...全文
415 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
peng2739956 2017-03-06
  • 打赏
  • 举报
回复
做这个是有什么 特别的业务要求吗?
zhlym 2017-03-06
  • 打赏
  • 举报
回复
建议用 HttpAnalyzer 这样的跟踪软件跟一下,看是否需要COOKIES这类的东西
yule5xiang0 2017-03-05
  • 打赏
  • 举报
回复
遇到同样问题 求指点
yule5xiang0 2017-03-05
  • 打赏
  • 举报
回复
见一哥们也是这个问题 结帖了但没把解决方案公布出来http://bbs.csdn.net/topics/391867132
yule5xiang0 2017-03-05
  • 打赏
  • 举报
回复
和我遇到问题一模一样 楼主找到解决办法没 被他折磨的寝室难安 求指导 加我QQ啊:1292674435

111,097

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧