按照开发文档配置的域名,配置不进去,第一次可以保存成功了,后面因需求关系需要增加域名,结果保存不了。
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;