How can I set an HTTP Proxy (WebProxy) on a WCF client-side Service proxy?

后端 未结 5 731
孤独总比滥情好
孤独总比滥情好 2020-11-29 00:57

How can I set the HTTP proxy programmatically, on a WCF client, without using the default proxy?

Proxies, proxies, proxies.

According to the WCF model of

5条回答
  •  抹茶落季
    2020-11-29 01:33

    You could also try this :

    Programmatically get whatever binding you are using,and then set the proxy on it directly e.g.

    var binding = new WSDualHttpBinding("WSDualHttpBinding_IMainService");
    binding.ProxyAddress = new Uri("http://192.168.5.1:3128");
    

    where "WSDualHttpBinding_IMainService" is the name of your binding from your config file. Also you have to set UseDefaultWebProxy=false; otherwise your proxy will be ignored.

提交回复
热议问题