小编use*_*574的帖子

在HTTP客户端中使用公共代理服务器

我正在尝试使用公共代理服务器(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();
Run Code Online (Sandbox Code Playgroud)

在执行rawHTML的代码后,我得到了 "pageok -managed by puppet - hostingcms02 pageok"

如果我注释掉HttpWRequest.Proxy = myProxy;,我会得到网站内容.

c# proxy http

5
推荐指数
1
解决办法
1995
查看次数

标签 统计

c# ×1

http ×1

proxy ×1