C#
Languages & HTTP Clients

C# / .NET (HttpClient) proxy integration

.NET routes HttpClient traffic through a WebProxy configured on the HttpClientHandler. Set the Aethyn endpoint and credentials, and every request exits through a residential IP.

Setup steps

  1. 1Create a WebProxy pointing at proxy.aethyn.io:2099.
  2. 2Set Credentials with your Aethyn username (incl. targeting) and password.
  3. 3Attach the proxy to an HttpClientHandler.
  4. 4Use that handler when constructing HttpClient.

Code

HttpClient with WebProxy
using System.Net;
using System.Net.Http;

var proxy = new WebProxy("http://proxy.aethyn.io:2099")
{
    Credentials = new NetworkCredential(
        "aethyn-XXXXX-country-us", "PASSWORD")
};

var handler = new HttpClientHandler { Proxy = proxy, UseProxy = true };
using var client = new HttpClient(handler);

var body = await client.GetStringAsync("https://httpbin.org/ip");
Console.WriteLine(body);

Replace aethyn-XXXXX and PASSWORD with your dashboard credentials. See the full targeting reference and protocol/port list.

Tips

  • Reuse one HttpClient instance for the app's lifetime.
  • Put targeting suffixes in the NetworkCredential username.
  • Set Timeout on the HttpClient to avoid hanging requests.

C# / .NET (HttpClient) proxy FAQ

Does HttpClient support authenticated proxies?
Yes. Set the WebProxy.Credentials to a NetworkCredential with your Aethyn username and password.

Ready to wire up C# / .NET (HttpClient)?

Get your credentials and route your first C# / .NET (HttpClient) request through residential IPs in minutes.

Docs, solutions & blog

Related integrations

All integrations