views:

33

answers:

1

What may cause System.Net.WebException: The remote server returned an error: (407) Proxy Authentication Required. Windows webclient on Windows 7 virtual machine

        WebClient client = new WebClient();
        client.DownloadFile(Uri, "test.html"); // fails
        string html = client.DownloadString(Uri); // fails 

I can't see any proxy settings in Internet Explorer and on the same box Com Automation driven from Visual Foxpro works without any proxy.

oxmlhttp = createobject("microsoft.xmlhttp")
oxmlhttp.open('GET', lcURL, .t.)
oxmlhttp.send()

Once rebooting box made it disappear , but right now after rebooting it persists.

A: 

Not sure how robust it is but adding these lines before invoking download solved my problem.

IWebProxy theProxy = client.Proxy;
if (theProxy != null)
{
    theProxy.Credentials = CredentialCache.DefaultCredentials;
}
MicMit