【发布时间】:2012-05-06 16:53:46
【问题描述】:
这是我的代码,确保这些请求通过远程代理传递的最佳方法是什么?
String openUrl = @"www.site.com/page.html";
WebClient myClient = new WebClient();
myClient.UseDefaultCredentials = true;
IWebProxy theProxy = myClient.Proxy;
if (theProxy != null)
{
theProxy.Credentials = CredentialCache.DefaultCredentials;
}
myClient.Proxy = WebRequest.DefaultWebProxy;
string webPageString = myClient.DownloadString(openUrl);
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(webPageString);
【问题讨论】:
-
您希望每个请求都通过您的代理服务器吗?
-
不,只有在执行此功能时,我希望通过外部代理服务器路由此特定请求
标签: c# winforms proxy webclient