189 8069 5689

如何解决解决iis7.5服务器上.net获取不到https页面的信息-创新互联

这篇文章主要介绍“如何解决解决iis7.5服务器上.net 获取不到https页面的信息”,在日常操作中,相信很多人在如何解决解决iis7.5服务器上.net 获取不到https页面的信息问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”如何解决解决iis7.5服务器上.net 获取不到https页面的信息”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

创新互联公司是一家朝气蓬勃的网站建设公司。公司专注于为企业提供信息化建设解决方案。从事网站开发,网站制作,网站设计,网站模板,微信公众号开发,软件开发,小程序设计,十载建站对成都湿喷机等多个领域,拥有丰富的网站运维经验。

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

GET的方法:

复制代码 代码如下:


///


        /// 获取URL访问的HTML内容 获取https 页面的
        ///

        /// URL地址
        /// HTML内容
        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的方法:

复制代码 代码如下:


///


        /// post提交数据到https
        ///

        ///
        ///
        ///
        ///
        ///
        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;
        }


到此,关于“如何解决解决iis7.5服务器上.net 获取不到https页面的信息”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注创新互联网站,小编会继续努力为大家带来更多实用的文章!


当前题目:如何解决解决iis7.5服务器上.net获取不到https页面的信息-创新互联
当前地址:http://cdxtjz.cn/article/eijpi.html

其他资讯