Fix it so that .NET apps can access HTTP thru authenticating proxy server by default
If you run a .NET app that needs to talk to the web, and you're behind an authenticating proxy server, then that app will fail to talk to the web.
Internet Explorer and Google Chrome work, Visual Studio and loads of other Microsoft apps will work. They can all talk to the web. But every .NET-based app or website I've ever seen will fail.
The implications of this are profound. I've seen umpteen forum posts over the years where people are scratching their heads, wondering what's wrong. I've seen IT guys re-route their users thru special-case connections to the web, because the user has to access some web functionality.
I've installed a piece of software that needs to authenticate a license key over the web... only to fail. And then you have to call their support lines.
I've seen Umbraco and Orchard CMS users fail to access the online galleries of themes and widgets. No-one - developers, users, IT guys - have a clue what's wrong or how to fix it.
Even Microsoft's .NET apps fail: if I try to run WCF's svcutil.exe on a remote service, it will fail... because I'm behind an authenticating proxy server.
And yet the fix is so simple. Simple, but no-one knows about it... no-one! Take a look at this StackOverflow question:-
The simple, simple fix is to add this to your .NET app's app/web config file:-
<defaultProxy useDefaultCredentials="true" />
But since no-one knows about this, let's end the years of confusion and have .NET 4.5 change the default value of useDefaultCredentials from false to true. Problem solved, and everyone can get on with their lives.
If Internet Explorer "just works", why can't .NET-build apps "just work"?
And for a better-argued case, see here:-
You are a life saver. I was going nuts !!!
If I have another child, I will name him Andrew :)
Ieuan Walker commented
How would you do this in .net Core?
3 days spent on this and about 2000 posts read before to input the right sequence of words in Google and get your page . THANK YOU!!!!!!
omfg why is this the only page i can read this.
what´s wrong with this world. 4 days search to find this link :)))
James Hood commented
It would also be nice if defaultProxy would use a manually configured proxy since it currently appears to just work for wpad/pac auto-configured proxies. To echo others in the comments, if the user enters a username/password in IE/Edge for a proxy, it would be nice if that would also work in other places like .NET.
You can use web.config or code to use proxy in .net application . here is good article to use proxy in .net application - http://goo.gl/bLDAHp
In my case changing the configuration file did not work. However adding ip(in my case) to the exception in IE => Tools => Internet Options => Connections => LAN Settings => Advanced => Exceptions . Sharing because it might help some one.
Thanks for sharing this Andrew.
Your a top man, you were right, nobody knows about this, your article has been a life saver, our web service calls our now working behind an authenticated proxy. Thank you for sharing...
Andrew Webb commented
It's been over three years since I created this suggestion, and still no response at all from Microsoft. Very sad. And obviously we've missed the .NET 4.5 boat.
However, I'm pleased to see how this suggestion, and my related answer on StackOverflow, has obviously helped a lot of people with this serious, but easily preventable, problem.
Words can't say enough how amazingly brilliant your solution is. No other article on the web does not address the problem so well and precisely! Simply brilliant!
Hi, will this work if its a SQUID proxy with an required authentication set up.
We have one such proxy and the current settings don't seem to take effect.
Andrew, you are fantastic. I am definitely one of the people who spent hours scratching their head wondering why the .NET app I support was not able to connect through an authenticating proxy. This was the answer, and it would have saved many troubleshooting hours and much stress if this "just worked" as it does in IE.
Thanks very much! Came across this after several hours of searching. My 407 error (Proxy Authentication Required) is gone.
Brilliant Answer. Solved my problem, so easily. gotta love a simple fix. well done.
Eric Lawrence commented
For what it's worth, Internet Explorer only "Just works" if the credentials are NTLM/Negotiate. http://blogs.msdn.com/b/ieinternals/archive/2012/08/03/manual-proxy-authentication-requiring-basic-or-digest-breaks-many-applications.aspx
Which better? Using proxy website like ninja proxy http://www.ninjaproxy.eu or proxy server to hide ip?
Thomas Levesque commented
@Pedro, I think it only works if the proxy uses NTLM authentication. I have a Squid proxy with basic authentication, and it doesn't work either.
It doesn`t work. Although I put in my app.config this sentence:
<defaultProxy useDefaultCredentials="true" />
Still I'm getting this error in my .Net pgm :
HTTP status 407: Proxy Authentication Required.
Bryan Melo commented
I need some help, i'm currently facing the same problem I can go on firefox and surf the web, but i can't use any of the programs that access the internet. This is one of the errors i get when trying to play Dayz. tinypic.com/r/10rsevs/6