WebClient vs. Proxy Authentication 407 error

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top