The following code works for me:
var webProxy = WebProxy.GetDefaultProxy(); webProxy.UseDefaultCredentials = true; WebRequest.DefaultWebProxy = webProxy;
Unfortunately, WebProxy.GetDefaultProxy()
is deprecated. What else should I be doing?
(using app.config to set the defaultProxy settings is not allowed in my deployment)
Setting up the credentials for the Proxy Server: In Windows 10 menu, go to Settings (WinKey+I) and search for "Credential Manager". Under Windows Credentials, add a new entry for Windows Credentials. Enter the Proxy Server address (without the port number), your domain user name and the password.
Select the Start button, then select Settings > Network & Internet > VPN. Select the VPN connection, then select Advanced options. Under VPN proxy settings, select the type of proxy setup you want to use, then enter the proxy server information for that VPN connection.
For those who, unlike Brian Genisio, are able to set the contents of their application's config file:- don't do anything in code. Instead add this to your app.config / web.config.
<system.net> <defaultProxy useDefaultCredentials="true" /> </system.net>
Really and truly the default for using the default credentials should be "true"; I've seen this issue confuse so many people - developers, users, IT guys.
For more info see here:- http://sticklebackplastic.com/post/2007/01/26/Poxy-proxies.aspx
UPDATE: I've created this issue/idea for Microsoft to change the default of useDefaultCredentials from false to true so that this whole problem goes away and .NET apps "just work"; please vote it up if you agree:
http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2397357-fix-it-so-that-net-apps-can-access-http-thru-auth
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With