asp.net 中如何请求一个其它网站的页面

HttpWebRequest web = (HttpWebRequest)HttpWebRequest.Create(url);
            web.ServicePoint.Expect100Continue = false;
            web.AllowAutoRedirect = false;
            web.ContentType = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*";
            web.Accept = this.Request.AcceptTypes.ToString();
            web.Method = "GET";
            web.UserAgent = this.Request.UserAgent;

            HttpWebResponse res = (HttpWebResponse)web.GetResponse();
            string html = new StreamReader(res.GetResponseStream(), Encoding.UTF8).ReadToEnd();
            return html;

posted @ 2010-07-21 16:55  zziss  阅读(277)  评论(0编辑  收藏  举报