苏飞论坛

标题: CsharpHttpHelper_Demo报错:Unable to connect to the remote server [打印本页]

作者: jollytao    时间: 2015-11-16 19:49
标题: CsharpHttpHelper_Demo报错:Unable to connect to the remote server
求助站长:

前几天买了“HttpHelper万能框架”,并下载了其中的“CsharpHttpHelper_Demo”后, 测试“HttpGet_Demo.aspx.cs”的时候,执行到下段拿response时,一直出现"Unable to connect to the remote server”的error message, 请问下这个跟我的vs环境有关吗?还是其他?

                //请求数据
                using (response = (HttpWebResponse)request.GetResponse())
                {
                    GetData(item, result);
                }

我用.NET 4.0的操作的,程序正常运行,网页正常打开; 测试其中的demo的时候,用了一下这段在demo中既有的代码:
但是一直报错,不知道为何???把URL改成www.baidu.com啥的,都是一样的错。 求指导啊,先谢谢啦!

            //创建Httphelper对象
            HttpHelper http = new HttpHelper();
            //创建Httphelper参数对象
            HttpItem item = new HttpItem()
            {
                URL = "http://www.sufeinet.com",//URL     必需项   
                Method = "get",//URL     可选项 默认为Get   
                ContentType = "text/html",//返回类型    可选项有默认值   
                //ContentType = "application/x-www-form-urlencoded",//返回类型    可选项有默认值   
            };
            //请求的返回值对象
            HttpResult result = http.GetHtml(item);
            //获取请请求的Html
            string html = result.Html;
            //获取请求的Cookie
            string cookie = result.Cookie;

            //状态码
            HttpStatusCode code = result.StatusCode;
            //状态描述
            string Des = result.StatusDescription;
            if (code == HttpStatusCode.OK)
            {
                //状态为200
            }




作者: 站长苏飞    时间: 2015-11-17 11:24
Demo只是测试代码,不能正常运行,大部分是我测试效果的。呵呵,可以参考在线生成的,这个不用管他。
作者: jollytao    时间: 2015-11-17 20:01
Okay, Thank you!




欢迎光临 苏飞论坛 (http://www.sufeinet.com/) Powered by Discuz! X3.4