The remote server responded with an error: (407) Proxy authentication required

I get this error when calling a web service:

"The remote server responded with an error: (407) Proxy authentication required."

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

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

or using DefaultCredentials in code. My problem is that the web service call works unchanged.

There seems to be a non-model solution involving Machine.config, but what is it? At the moment, I can’t get to the box machine.config file to see how it looks. I tried updating the machine.config file as follows, but I still get 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> 
+58
Apr 05 2018-10-10T00:
source share
6 answers

Just add this to your configuration

 <system.net> <defaultProxy useDefaultCredentials="true" > </defaultProxy> </system.net> 
+102
Sep 28 '12 at 6:31
source share

In the following code, we do not need to hardcode the credentials.

 service.Proxy = WebRequest.DefaultWebProxy; service.Credentials = System.Net.CredentialCache.DefaultCredentials; ; service.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials; 
+45
Aug 20 '12 at 10:13
source share

Contact your firewall specialist. They open a firewall for PROD servers, so there is no need to use a proxy.

Thank you, your advice helped me solve my problem:

Had to set credentials in two places to get past error 407:

 HttpWebRequest webRequest = WebRequest.Create(uirTradeStream) as HttpWebRequest; webRequest.Proxy = WebRequest.DefaultWebProxy; webRequest.Credentials = new NetworkCredential("user", "password", "domain"); webRequest.Proxy.Credentials = new NetworkCredential("user", "password", "domain"); 

and voila!

+19
Sep 14 '10 at 6:59
source share

Probably the machine or web.config in prod has settings in the configuration; you probably won't need a proxy tag.

 <system.net> <defaultProxy useDefaultCredentials="true" > <proxy usesystemdefault="False" proxyaddress="http://<ProxyLocation>:<port>" bypassonlocal="True" autoDetect="False" /> </defaultProxy> </system.net> 
+6
Apr 05 '10 at 22:51
source share
 HttpWebRequest webRequest = WebRequest.Create(uirTradeStream) as HttpWebRequest; webRequest.Proxy = WebRequest.DefaultWebProxy; webRequest.Credentials = new NetworkCredential("user", "password"); webRequest.Proxy.Credentials = new NetworkCredential("user", "password"); 

Successfully.

+3
Jun 08 2018-12-12T00:
source share

I had a similar proxy issue. In my case, this was enough:

 webRequest.Proxy.Credentials = new NetworkCredential("user", "password", "domain"); 
+2
Dec 05 '11 at 13:12
source share



All Articles