我正在尝试使用公共代理服务器 (http://www.unblockwebnow.info/) 将 HTTP 请求发送到目标站点,例如http://stackoverflow.com :)
我的 HTTP 客户端具有以下架构:
string url = "http://stackoverflow.com";
HttpWebRequest HttpWRequest = (HttpWebRequest)WebRequest.Create(url);
HttpWRequest.Method = "GET";
WebProxy myProxy = new WebProxy();
myProxy.Address = new Uri("http://www.unblockwebnow.info/");
HttpWRequest.Proxy = myProxy;
HttpWebResponse HttpWResponse = (HttpWebResponse)HttpWRequest.GetResponse();
StreamReader sr = new StreamReader(HttpWResponse.GetResponseStream(), encoding);
var rawHTML = sr.ReadToEnd();
sr.Close();
执行 rawHTML 的代码后,我得到"pageok -managed by puppet - hostingcms02 pageok"
如果我注释掉HttpWRequest.Proxy = myProxy;
行,我会得到网站内容。