Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTP status 407: Proxy authentication required Error when calling web service

I have spent two hours on this error "HTTP status 407: Proxy authentication required Error " when calling a web service, my code is like following

WebProxy oWebProxy = new System.Net.WebProxy(ProxyServer, ProxyPort);
oWebProxy.Credentials = new NetworkCredential(ProxyUser,ProxyPassword,ProxyDomain);
oserv.Proxy = oWebProxy;
oserv.Credentials = new NetworkCredential(theusername, thepassword);

I have verified that the proxy address, user id password are all correct, and I could access the web service thru the IE in same pc, but when I run the code with VS, the error keeps popup. I have tried the UserDefaultCredentials=true as well, but no luck.

Any idea?

like image 926
peanut Avatar asked Oct 14 '22 12:10

peanut


1 Answers

Popping a<defaultProxy /> element into in app.config / web.config under <system.net> with useDefaultCredentials="true" may well do the job.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.net>
    <defaultProxy useDefaultCredentials="true" />
  </system.net>
</configuration>
like image 171
tomfanning Avatar answered Oct 18 '22 22:10

tomfanning