title: System.Net.WebClient vs. Proxy Authentication 407 error
body: <p>I'm trying to figure out how to robustly handle proxy authentication errors (HTTP 
  407 status code) when using the System.Net.WebClient class.</p>
  
  <p>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.</p>
  
  <p>Here's the basic code we are using:</p>
  
  <pre><code>using System.Net;
  
  string url = "http://www.mysite.com";
  WebClient webClient = new WebClient();
  byte[] data = webClient.DownloadFile(url);
  </code></pre>
  
  <p>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.</p>
  
  <p>It seems that we could use WebClient.UseDefaultCredentials, but this 
  seems redundant if WebClient is using the system settings anyway.</p>
  
  <p>Any help is appreciated.</p>