Исходный код вики Настройка Proxy для http клиента
Версия 5.1 от Alexandr Fokin на 2021/12/02 19:21
Последние авторы
| author | version | line-number | content |
|---|---|---|---|
| 1 | |||
| 2 | |||
| 3 | {{code language="c#"}} | ||
| 4 | IWebProxy proxy = WebRequest.GetSystemWebProxy(); | ||
| 5 | proxy.Credentials = CredentialCache.DefaultCredentials; | ||
| 6 | {{/code}} | ||
| 7 | {{code language="c#"}} | ||
| 8 | .ConfigurePrimaryHttpMessageHandler( | ||
| 9 | () => | ||
| 10 | { | ||
| 11 | HttpClientHandler handler = new HttpClientHandler(); | ||
| 12 | handler.UseProxy = true; | ||
| 13 | handler.DefaultProxyCredentials = CredentialCache.DefaultNetworkCredentials; | ||
| 14 | return handler; | ||
| 15 | } | ||
| 16 | ) | ||
| 17 | {{/code}} | ||
| 18 | |||
| 19 | |||
| 20 | Ссылки: | ||
| 21 | |||
| 22 | How should I set the default proxy to use default credentials? | ||
| 23 | https://stackoverflow.com/questions/299940/how-should-i-set-the-default-proxy-to-use-default-credentials | ||
| 24 | |||
| 25 | HttpClient and using proxy - constantly getting 407 | ||
| 26 | https://stackoverflow.com/questions/29856543/httpclient-and-using-proxy-constantly-getting-407 |