HTTP Error 407 – Proxy authentication required

Recently I deployed an application into the live environment at work and all was running smoothly until a proxy setting change suddenly stopped the app being able to talk to the outside world. I didn’t much fancy having to rework the code to allow proxy authentication, so I did a bit of searching on Google, and came up with the following block to go into the app.config file.

<system.net>
  <defaultProxy enabled="true" useDefaultCredentials="true">
    <proxy bypassonlocal="True" proxyaddress="http://proxy"/>
  </defaultProxy>
</system.net>

Adding the section to the config file instructs the assembly to provide the default credentials to the proxy when requested, and saved me having to recompile and go through the system test phase or of product lifecycle. Hopefully it might save someone else the pain, too.

2 thoughts on “HTTP Error 407 – Proxy authentication required

  1. hi..
    I have simmilar problem. Maybe you can help ;)

    I want to add web reference but I’m on proxy+password enabled network.
    How to specify username and password in default proxy setting?

    Thanks..

  2. Is the problem with adding the web reference itself (Visual Studio can’t get through the proxy) or when you try to consume from the application? I’m assuming it is a Visual Studio issue (since the example above tells you how to access the web service from the app). I believe there is a way to edit VS’s config file to support default proxy authentication, but I can’t find it right now. The other option you have is to manually download the WSDL from the server, and run it through wsdl.exe to build the proxy object.

    HTH

Comments are closed.