开发者

Windows 7 Virtual machine .Net Webclient System.Net.WebException: The remote server returned an error: (407) Proxy Authentication Required

开发者 https://www.devze.com 2023-01-14 14:16 出处:网络
What may cause System.Net.WebException: The remote server returned an error: (407) Proxy Authen开发者_JAVA百科tication Required. Windows webclient

What may cause System.Net.WebException: The remote server returned an error: (407) Proxy Authen开发者_JAVA百科tication 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.


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;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消