当前位置:编程学习 > C#/ASP.NET >>

采集:无法从传输连接中读取数据: 连接已关闭





贴代码:


 HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(strURL);
            myHttpWebRequest.ContentType = "text/html";
            myHttpWebRequest.Method = "GET";
            myHttpWebRequest.Referer = strReferer;
            myHttpWebRequest.Headers.Add("cookie:" + cookieHeader);
            myHttpWebRequest.Timeout = 1000000;
            HttpWebResponse response = null;
            System.IO.StreamReader sr = null;
            response = (HttpWebResponse)myHttpWebRequest.GetResponse();
            sr = new System.IO.StreamReader(response.GetResponseStream(), Encoding.GetEncoding(charset));
            string strResult = string.Empty,temp=string.Empty;
            //方式一
           while(string.IsNullOrEmpty(temp=sr.ReadLine()))
            {
                strResult += temp;
            }
            //方式二
            //string strResult = sr.ReadToEnd();
            return strResult;


我请求的地址中间有跳转,我post数据给它后,他会跳转两次。我要拿最后的源代码。
总是报错,各位大大指教阿。
--------------------编程问答-------------------- 不能沉阿。
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,