首页 > 网站 > IIS > 正文

解决iis7.5服务器上.net 获取不到https页面的信息

2024-08-29 03:13:24
字体:
来源:转载
供稿:网友

我的获取页面需要cookie,不需要的可以去掉;

GET的方法:

代码如下:
/// <summary>
        /// 获取URL访问的HTML内容 获取https 页面的
        /// </summary>
        /// <param name="Url">URL地址</param>
        /// <returns>HTML内容</returns>
        public static string GetWebContent(string Url, CookieContainer cookieContainer)
        {
            string strResult = "";
            try
            {
                ServicePointManager.Expect100Continue = true;
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
                request.CookieContainer = cookieContainer;
                request.Timeout = 30000;
                request.Headers.Set("Pragma", "no-cache");

                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                Stream streamReceive = response.GetResponseStream();

                Encoding encoding = Encoding.GetEncoding("utf-8");
                StreamReader streamReader = new StreamReader(streamReceive, encoding);
                strResult = streamReader.ReadToEnd();
            }
            catch
            {

            }
            return strResult;
        }

 POST的方法:

代码如下:
/// <summary>
        /// post提交数据到https

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表