WebClient vs. Proxy Authentication 407 error

  • Thread starter Thread starter Daniel
  • Start date Start date
D

Daniel

I'm trying to figure how to robustly handle proxy authentication errors (HTTP
407 status code) when using the System.Net.WebClient class.

In the field, we see many users receiving a 407 proxy authentication
WebException, but I'm not sure what a good default strategy is. In .Net
2.0/3.5, the proxy authentication settings are supposed to be inherited from
the Internet Explorer system settings. Firefox, Opera and Chrome use these
same settings.

Here's the basic code we are using:

using System.Net;

string url = "http://www.example.com";
WebClient client = new WebClient();
byte[] fileBuffer = client.DownloadFile(url);

When this code fails, we open the user's browser and send them to a help
page. From our web logs, we know these customers can successfully connect in
their browsers. Perhaps they are manually entering their proxy user name and
password before they get to our help page? We don't know.

It seems that we could use WebClient.UseDefaultCredentials, but to me this
seems redundant if WebClient is using the system settings anyway.

Any help is appreciated.
 
Back
Top