如何在没有 WebClient c.net 凭据的情况下设置代理
我有代理和端口号,但没有凭据。如何设置 Web 客户端以通过该代理,下面的代码给出错误
string proxyserver = "http://10.0.0.127:8080/";
IWebProxy proxy = new WebProxy(proxyserver);
proxy.Credentials = CredentialCache.DefaultCredentials;
WebClient.Proxy = proxy;
byte[] rawResponse = WebClient.UploadFile(url, filename);
如果我使用 CredentialCache,我没有身份验证类型和网络凭据。有没有其他方法可以将我的代理分配给 WebClient
谢谢,
michaled
I have a proxy and port number but don't have credentials .how can iset the webclient to go through that proxy ,the below code is giving error
string proxyserver = "http://10.0.0.127:8080/";
IWebProxy proxy = new WebProxy(proxyserver);
proxy.Credentials = CredentialCache.DefaultCredentials;
WebClient.Proxy = proxy;
byte[] rawResponse = WebClient.UploadFile(url, filename);
If i use CredentialCache i don't have authenticationtype and networkcredential. Is there any other way to assign my proxy to the WebClient
thanks,
michaled
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
除非您提供的代码只是实际代码的一部分,否则您需要使用 Proxy 属性将创建的代理与 WebClient 对象关联起来(请参阅下面的文档)
: com/en-us/library/system.net.webclient.proxy.aspx" rel="nofollow">WebClient.Proxy 属性
如果您已经这样做了,请忽略它。
Unless the code you have supplied is only a portion of your actual code, you will need to associate the proxy created with the WebClient object using the Proxy property (See documentation below):
WebClient.Proxy Property
If you are already doing so then disregard this.