解决iis7.5服务器上.net 获取不到https页面的信息
我的获取页面需要cookie,不需要的可以去掉;
GET的方法:
///<summary> ///获取URL访问的HTML内容获取https页面的 ///</summary> ///<paramname="Url">URL地址</param> ///<returns>HTML内容</returns> publicstaticstringGetWebContent(stringUrl,CookieContainercookieContainer) { stringstrResult=""; try { ServicePointManager.Expect100Continue=true; ServicePointManager.SecurityProtocol=SecurityProtocolType.Ssl3; HttpWebRequestrequest=(HttpWebRequest)WebRequest.Create(Url); request.CookieContainer=cookieContainer; request.Timeout=30000; request.Headers.Set("Pragma","no-cache");
HttpWebResponseresponse=(HttpWebResponse)request.GetResponse(); StreamstreamReceive=response.GetResponseStream();
Encodingencoding=Encoding.GetEncoding("utf-8"); StreamReaderstreamReader=newStreamReader(streamReceive,encoding); strResult=streamReader.ReadToEnd(); } catch {
} returnstrResult; }