How do I use a proxy ip #1892
-
|
How do I use a proxy ip |
Beta Was this translation helpful? Give feedback.
Answered by
glennawatson
Jun 16, 2026
Replies: 1 comment
-
|
Refit does not manage the proxy itself - you set it on the Plain usage: var handler = new HttpClientHandler
{
Proxy = new WebProxy("http://your-proxy-ip:port"),
UseProxy = true,
// optional:
// Credentials = new NetworkCredential("user", "pass")
};
var client = new HttpClient(handler)
{
BaseAddress = new Uri("https://api.example.com")
};
var api = RestService.For<IMyApi>(client);With services
.AddRefitClient<IMyApi>()
.ConfigureHttpClient(c => c.BaseAddress = new Uri("https://api.example.com"))
.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler
{
Proxy = new WebProxy("http://your-proxy-ip:port"),
UseProxy = true
}); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
glennawatson
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Refit does not manage the proxy itself - you set it on the
HttpMessageHandlerthat backs theHttpClient, then hand that client to Refit.Plain usage:
With
IHttpClientFactory/ DI: