Weclient class and proxies

  • Thread starter Thread starter Jalil
  • Start date Start date
J

Jalil

My code below works fine when I am no using web proxy:


//login and pwd is for the remote server.
NetworkCredential netCredential = new NetworkCredential(login,pwd);
WebClient client = new WebClient();
client.Credentials = netCredential;
Console.WriteLine(client.DownloadString(RequestUrl));

However, when I run behind a proxy I get an exception that I need to
authenticate to the proxy.

How would I do this in my program? I read in the doc the WebClient by
default uses IE proxy settings? Is that true?

Thanks,

-Jalil
 
Sloan,

Yes, I had seen this info before. It says:

The Proxy property identifies the IWebProxy instance that communicates with
remote servers on behalf of this WebClient object. The proxy is set by the
system using configuration files and the Internet Explorer Local Area Network
settings. To specify that no proxy should be used, set the Proxy property to
the proxy instance returned by the GetEmptyWebProxy method.

But how would I set this property to the what IE is configured to use?

Thanks,

-Jalil
 
Back
Top