C# 与WebProxy的web服务连接
我有一个与web服务的连接,可以选择添加代理详细信息。这个很好用。然而,当代理不仅仅是一个地址,而且是一个带有文件名的地址时,它似乎失败了。。。比如,C# 与WebProxy的web服务连接,c#,.net,web-services,proxy,C#,.net,Web Services,Proxy,我有一个与web服务的连接,可以选择添加代理详细信息。这个很好用。然而,当代理不仅仅是一个地址,而且是一个带有文件名的地址时,它似乎失败了。。。比如, myproxy.com/proxypac.asp 最后的这个文件名似乎给我带来了问题。我正在初始化我的WebProxy System.Net.WebProxy wp = new System.Net.WebProxy(location.ProxyAddress, location.ProxyPort); 有人能提供一些建议吗?您是否尝试过:
myproxy.com/proxypac.asp
最后的这个文件名似乎给我带来了问题。我正在初始化我的WebProxy
System.Net.WebProxy wp = new System.Net.WebProxy(location.ProxyAddress, location.ProxyPort);
有人能提供一些建议吗?您是否尝试过:
WebProxy proxy = new WebProxy(@"http://myproxy.com/proxypac.asp");
或
解决方法是打开文件并检查其内容,以查看代理地址和端口
如果下载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";
}
您是否尝试过:
WebProxy proxy = new WebProxy(@"http://myproxy.com/proxypac.asp");
或
解决方法是打开文件并检查其内容,以查看代理地址和端口
如果下载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";
}
“它似乎失败了”。。。除了哪一个例外?你怎么知道呢?看看这篇文章:错误很简单;'远程服务器返回错误:(400)请求不正确。““似乎失败了”。。。除了哪一个例外?你怎么知道呢?看看这篇文章:错误很简单;'远程服务器返回错误:(400)请求错误。'