【问题标题】:Windows 7 Virtual machine .Net Webclient System.Net.WebException: The remote server returned an error: (407) Proxy Authentication RequiredWindows 7 虚拟机 .Net Webclient System.Net.WebException:远程服务器返回错误:(407)需要代理身份验证
【发布时间】:2010-09-01 03:00:13
【问题描述】:

什么可能导致 System.Net.WebException:远程服务器返回错误:(407)需要代理身份验证。 Windows 网络客户端 在 Windows 7 虚拟机上

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

我在 Internet Explorer 中看不到任何代理设置,并且在同一个盒子上,由 Visual Foxpro 驱动的 Com Automation 无需任何代理即可工作。

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

一旦重启框就消失了,但现在重启后它仍然存在。

【问题讨论】:

    标签: .net proxy webclient virtual-machine


    【解决方案1】:

    不确定它有多强大,但在调用下载之前添加这些行解决了我的问题。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-12-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多