To proxy external requests set the Proxy
property of HttpClientHandler
:
private static HttpClient client
= new HttpClient(new HttpClientHandler()
{
Proxy = new WebProxy("localhost", 8888)
});
This will not work for localhost requests since these bypass proxies by default. Instead you can suffix the request URL with .fiddler
. This is why it is a good idea to store your API endpoints in app/web.config:
<add key="ApiEndpoint" value="http://localhost.fiddler:49978" />