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

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

热门标签:科大讯飞语音识别系统 电商新玩法 人工智能 网站排名优化 客户服务 国美全国运营中心 百度AI接口 电销业务

我的获取页面需要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
        /// /summary>
        /// param name="posturl">/param>
        /// param name="postdata">/param>
        /// param name="header">/param>
        /// param name="cookieContainer">/param>
        /// returns>/returns>
        public static string SetPostHtml(string posturl, string postdata, HttpHeader header, CookieContainer cookieContainer)
        {
            string restr = "";
            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
            HttpWebRequest request = null;
            HttpWebResponse response = null;
            request = (HttpWebRequest)WebRequest.Create(posturl);
            request.CookieContainer = cookieContainer;
            request.Method = header.method;
            request.Referer = header.Referer;
            request.ContentType = header.contentType;
            byte[] postdatabyte = Encoding.UTF8.GetBytes(postdata);
            request.ContentLength = postdatabyte.Length;
            request.AllowAutoRedirect = false;
            request.KeepAlive = true;
            //提交请求
            Stream stream;
            stream = request.GetRequestStream();
            stream.Write(postdatabyte, 0, postdatabyte.Length);
            stream.Close();
            //接收响应
            response = (HttpWebResponse)request.GetResponse();
            using (StreamReader reader = new StreamReader(response.GetResponseStream()))
            {
                restr = reader.ReadToEnd().ToString();
            }
            return restr;
        }

您可能感兴趣的文章:
  • IIS 7中如何实现http重定向https
  • win2003 IIS 6.0实现全站https访问的配置方法
  • 有了SSL证书,如何在IIS环境下部署https
  • startssl申请SSL证书 并且配置 iis 启用https协议
  • win2000服务器在IIS中使用SSL配置HTTPS网站
  • win2003架设证书服务器及让IIS6启用HTTPS服务
  • IIS7.0 Windows Server 2008 R2 下配置证书服务器和HTTPS方式访问网站的教程图文详解
  • IIS7/IIS7.5 URL 重写 HTTP 重定向到 HTTPS的方法
  • IIS7下配置SSL的方法分析
  • World Wide Web Publishing 服务尝试删除 IIS 所有的 SSL 配置数据失败的几种方法
  • 在IIS6上开启https服务方法分享

标签:POS机 枣庄 拉萨 南平 咸宁 益阳 攀枝花 厦门

巨人网络通讯声明:本文标题《解决iis7.5服务器上.net 获取不到https页面的信息》,本文关键词  ;如发现本文内容存在版权问题,烦请提供相关信息告之我们,我们将及时沟通与处理。本站内容系统采集于网络,涉及言论、版权与本站无关。
  • 相关文章
  • 收缩
    • 微信客服
    • 微信二维码
    • 电话咨询

    • 400-1100-266