Popular blog tags

How to Use a HttpClient Proxy in C# .Net (WebProxy)

Published

How to Use a HttpClient Proxy in C# (WebProxy)

 

By default, HttpClient reads the proxy configuration from the system settings. Change that behavior and set a proxy with a WebProxy instance like this:

program.cs

// proxy configs
String proxyURL = "http://103.167.135.111:80";
WebProxy webProxy = new WebProxy(proxyURL);
// make the HttpClient instance use a proxy
// in its requests
HttpClientHandler httpClientHandler = new HttpClientHandler
{
  Proxy = webProxy
};
client = new HttpClient(httpClientHandler);

 

https://www.zenrows.com/blog/httpclient-proxy-c-sharp#how-to-use-proxy