Search code examples
httpclientwcf-web-api

setting a proxy on HttpClient that comes with WCF Web Api?


Does anyone know of a way to set a proxy on httpclient that comes with the wcf web api? I just want to be able to monitor all the traffic with fiddler.


Solution

  • You don't need to set a proxy on HttpClient to use fiddler. If you are hosting on localhost then check these tips here http://www.fiddler2.com/fiddler/help/hookup.asp#Q-LocalTraffic.

    if you really want to use a proxy then you can do it like this,

    var clientHandler = new HttpClientHandler();
    clientHandler.Proxy = new WebProxy(new Uri("http://..."));
    var httpClient = new HttpClient(clientHandler);