By pass Proxy when invoking a web service
<configuration>
<system.net>
<defaultProxy useDefaultCredentials=“true“ enabled = “False”> Set enabled as False to bypass proxy
<proxy usesystemdefault= “False“ proxyaddress=“http://a.com“ bypassonlocal=“True“ />
</defaultProxy>
</system.net>
</configuration>
To specify proxy credentials in your code
NetworkCredential credential = new NetworkCredential(“user”, “password”,“domain”);
Service1 _service = new Service1();
_service.PreAuthenticate = true;
_service.Credentials = credential;
_service.Proxy = WebProxy.GetDefaultProxy();
_service.Proxy.Credentials = CredentialCache.DefaultCredentials;

Advertisement

April 8, 2009 at 11:30 am
very simple and useful,thanks
April 8, 2009 at 12:15 pm
[...] this exception http 407 proxy authentication required? now you can solve this issue if you click here. just add the configuration in the post into your app.config or web.config I would like to thank [...]
October 7, 2011 at 4:31 pm
Hi,
Seems messy, where I can take a look at the app.config or web.config my server? then where to put these codes
Set enabled as False to bypass proxy
And the second reference codes, where should I put it to make it working.
NetworkCredential credential = new NetworkCredential(“user”, “password”,“domain”);
Service1 _service = new Service1();
_service.PreAuthenticate = true;
_service.Credentials = credential;
_service.Proxy = WebProxy.GetDefaultProxy();
_service.Proxy.Credentials = CredentialCache.DefaultCredentials;
Best regards,
juvyc
October 7, 2011 at 5:13 pm
web.config is located in root folder of your web application, usually where you have default.aspx.
the code should appear just before where you invoke service method.
if case of any confusion, please share your mail address and we will discuss