0

I have a situation where a user running my .NET application may be behind a proxy.

I have found that using

WebRequest.DefaultWebProxy.Credentials = CredentialCache.DefaultNetworkCredentials

at the beginning of the program always allows requests to work, whether or not a proxy is specified in the operating system Local Area Network (LAN) Settings dialog for example.

Without this line, when behind a proxy I get a 407 Proxy Authentication Required when making a request.

Is there any downside to always executing this line in my program? In most cases users do not go through a proxy, so is there significant additional overhead for example, either in code or over the wire, or any other disadvantages in using this when a proxy isn't present?

fractor
  • 1,534
  • 2
  • 15
  • 30

1 Answers1

0

From the documentation:

The Credentials property is an ICredentials instance that contains the authorization credentials to send to the proxy server in response to an HTTP 407 (proxy authorization) status code.

As only users behind a proxy will ever receive a 407, other users will not be affected.

stuartd
  • 70,509
  • 14
  • 132
  • 163
  • See also [this comment](http://stackoverflow.com/questions/299940/how-should-i-set-the-default-proxy-to-use-default-credentials/8180854#comment11286255_8180854) – stuartd Sep 22 '16 at 16:32