我与Web服务有连接,可以选择添加代理详细信息。这很好用。但是,当代理不只是一个地址,而是带有文件名的地址时,它似乎失败了......例如;
myproxy.com/proxypac.asp
最后这个文件名似乎给了我一些问题。我正在初始化我的WebProxy;
System.Net.WebProxy wp = new System.Net.WebProxy(location.ProxyAddress, location.ProxyPort);
任何人都可以提供任何指示吗?
答案 0 :(得分:1)
你试过了吗?
WebProxy proxy = new WebProxy(@"http://myproxy.com/proxypac.asp");
或者
WebProxy proxy = WebRequest.GetSystemWebProxy();
解决方法是打开文件并检查其内容,以查看您获得的代理地址和端口。
如果您下载myproxy.com/proxypac.asp
文件,它应如下所示:
function FindProxyForURL(url, host) {
// our local URLs from the domains below example.com don't need a proxy:
if (shExpMatch(url,"*.example.com/*")) {return "DIRECT";}
if (shExpMatch(url, "*.example.com:*/*")) {return "DIRECT";}
// URLs within this network are accessed through
// port 8080 on fastproxy.example.com:
if (isInNet(host, "10.0.0.0", "255.255.248.0")) {
return "PROXY fastproxy.example.com:8080";
}
// All other requests go through port 8080 of proxy.example.com.
// should that fail to respond, go directly to the WWW:
return "PROXY proxy.example.com:8080; DIRECT";
}