Thursday 30 June 2011

C# access webservice from behind proxy

I was trying to use C# .NET desktop application to access a webservice from my office, the web-service is behind a proxy firewall, I was annoyed by seeing the following error message

"- The request failed with HTTP status 407: Proxy Authentication Required"

By googling I found a solution that enables me to disable proxy "http://stackoverflow.com/questions/2131933/http-407-proxy-authentication-error-when-calling-a-web-service"

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>

1 comment: