
C# HttpClient Proxy Setup: Credentials, Timeouts and Verification
This guide shows how to configure an HttpClient proxy in C# on .NET 8: a `WebProxy` with `NetworkCredential`, the choice between `HttpClientHandler` and `SocketsHttpHandler`, correct client reuse with `IHttpClientFactory`, timeouts and cancellation, environment-variable configuration, bypass lists, and the two exceptions you will actually meet in production. It ends with a complete console program that opens a sticky residential session, verifies the exit IP and retries with a new session on failure. Everything below targets .NET 8 with top-level statements, but the API has been stable since .NET Core 3.0 and the same code compiles on .NET 6 and 7.





































