开发者

How to set proxy without credentials to WebClient c.net

开发者 https://www.devze.com 2023-03-25 08:51 出处:网络
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 er开发者_如何学运维ror

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 er开发者_如何学运维ror

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号