且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

远程服务器返回错误:(407)代理身份验证

更新时间:2022-10-20 16:23:12

只需添加这CONFIG

 < system.net> 
< defaultProxy useDefaultCredentials =真正的>
< / defaultProxy>
< /system.net>


I'm getting this error when I call a web service:

"The remote server returned an error: (407) Proxy Authentication Required".

I get the general idea and I can get the code to work by adding

myProxy.Credentials = NetworkCredential("user", "password", "domain");

or by using DefaultCredentials in code. My problem is that the call to the web service works in production without this.

It seems like there is a non code solution involving Machine.config, but what is it? At the moment I can't get to the production box's machine.config file to see what that looks like. I tried updating my machine.config as follows, but I still get the 407 error.

<system.net>
    <defaultProxy enabled="true" useDefaultCredentials="true">
        <bypasslist>
            <clear />
        </bypasslist>
        <proxy proxyaddress="myproxy:9000"
               usesystemdefault="false"
               bypassonlocal="true"
               autoDetect="False" />
    </defaultProxy>
</system.net>

Just add this to config

<system.net>
    <defaultProxy useDefaultCredentials="true" >
    </defaultProxy>
</system.net>