# Configure TrueProxies with C#

> Configure TrueProxies authentication, HTTP proxying, and sticky sessions with C# HttpClient and WebProxy.

Source: https://docs.trueproxies.com/integrations/csharp/

> **Use your own endpoints**
>
> The examples below use placeholders. Copy the connection host, ports, username, and proxy password from the **Username and password** tab of your service in the dashboard. See [How to connect](https://docs.trueproxies.com/proxy-instructions/how-to-connect/#connection-host-and-ports).

## HttpClient

```csharp
using System.Net;

var proxy = new WebProxy("http://YOUR_HOST:YOUR_HTTP_PORT")
{
    Credentials = new NetworkCredential("your_username", "your_password")
};

var handler = new HttpClientHandler { Proxy = proxy };
var client = new HttpClient(handler);

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

## SOCKS5

```csharp
using System.Net;

var proxy = new WebProxy("socks5://YOUR_HOST:YOUR_SOCKS_PORT")
{
    Credentials = new NetworkCredential("your_username", "your_password")
};

var handler = new HttpClientHandler { Proxy = proxy };
var client = new HttpClient(handler);

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

## Residential IPv4 country targeting

```csharp
var proxy = new WebProxy("http://YOUR_HOST:YOUR_HTTP_PORT")
{
    Credentials = new NetworkCredential("your_username-country-us", "your_password")
};
```

## Residential IPv4 sticky sessions

```csharp
var proxy = new WebProxy("http://YOUR_HOST:YOUR_HTTP_PORT")
{
    Credentials = new NetworkCredential("your_username-session-abc123", "your_password")
};
```

## Related guides

- [Connection and username format](https://docs.trueproxies.com/proxy-instructions/how-to-connect/)
- [HTTP CONNECT and SOCKS5](https://docs.trueproxies.com/proxy-instructions/proxy-protocols/)
- [Trusted IPs](https://docs.trueproxies.com/proxy-instructions/trusted-ips/)
- [Troubleshooting checklist](https://docs.trueproxies.com/support/)
