A proxy configured for one named HttpClient does not automatically configure every client returned by IHttpClientFactory. Keep the registration name and the requested name together.

services.AddHttpClient("via-proxy")
    .ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler
    {
        Proxy = new WebProxy("http://203.0.113.10:8080"),
        UseProxy = true
    });

Then retrieve that named configuration:

var client = factory.CreateClient("via-proxy");

The endpoint is illustrative. For permitted public-service requests, the HTTP proxy list provides candidates for the named client's WebProxy URL. Creating the default unnamed client elsewhere is a different lookup, even if both clients come from the same injected factory.

Configure connection-level proxy behavior on the primary handler rather than treating it as a destination request header. The factory can manage handler lifetimes separately from the HttpClient objects it returns.

If a typed client or another SDK owns the call, check which registration supplies its HttpClient. A correctly configured named client that is never used does not affect that SDK's network path.

Use this configuration for a stable routing policy. Changing a live handler between operations remains a separate concurrency and lifetime problem.

ХӀокхунах тера йаззамаш