不能使用api.weixin.qq.com作为request合法域名
网友回复:
在服务器后台
string url = "https://api.weixin.qq.com/sns/jscode2session?appid=****";
string html = null;
try
{
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
request.Method = "GET";
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
Stream ioStream = response.GetResponseStream();
StreamReader sr = new StreamReader(ioStream, Encoding.UTF8);
html = sr.ReadToEnd();
sr.Close();
ioStream.Close();
response.Close();
}
catch (System.Exception ex)
{
}
return html;
参考 连接