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