Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does HttpClientHandler have both Proxy and UseProxy properties?

Tags:

c#

.net

Why is it that having a Proxy property would not be enough?

If it is null, then don't use the proxy, if it is non-null, then use the provided proxy.

like image 507
alex Avatar asked Nov 09 '22 16:11

alex


1 Answers

Proxy property allows you specify a proxy to use by the HttpClientHandler.

UseProxy property allows indicates whether the handler uses a proxy for requests.

But if you want to use the default proxy, you don't have to defined it in Proxy property, is enough with set UseProxy.

When UseProxy is true and Proxy is null, the WebRequest.DefaultWebProxy is used.

DefaultWebProxy property reads proxy settings from the config file. If there is no one, the current user's Internet Explorer (IE) proxy settings are used.

like image 151
Arturo Menchaca Avatar answered Nov 14 '22 23:11

Arturo Menchaca