Proxy Authentication in .NET - for external API

白昼怎懂夜的黑 提交于 2019-12-02 21:15:36

This does not answer your question. But the error you are getting is clearly a Proxy authentication error.

You might want to either disable or enable the proxy.

To disable the proxy, in the App.config file add the following configuration

<system.net>
  <defaultProxy enabled="false" useDefaultCredentials="false">
    <proxy/>
    <bypasslist/>
    <module/>
  </defaultProxy>
</system.net>

To enable the proxy and to use the default proxy settings(specified in IE) add this configuration in your App.config

<system.net>
  <defaultProxy enabled="true" useDefaultCredentials="true">
    <proxy/>
    <bypasslist/>
    <module/>
  </defaultProxy>
</system.net>

One of the possible programmatic solutions is to create following proxy:

IWebProxy proxy=HttpWebRequest.GetSystemWebProxy();  
proxy.Credentials = CredentialCache.DefaultCredentials;  

and then assign this to any object that make the network call and accept a proxy,e.g:

WebClient client = new WebClient();
client.proxy= proxy;

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!