ServiceStack HttpUtils +代理服务器

问题描述:

我正在使用ServiceStack HttpUtils连接到第三方REST API。 如何在发出请求时通过代理服务器和代理端口?ServiceStack HttpUtils +代理服务器

感谢 rudrvij

HTTP Utils是一个包装了.NET的HttpWebRequest所以你可以使用相同的功能,以指定Proxy,如:

url.GetJsonFromUrl(requestFilter: req.Proxy = new WebProxy("http://webproxy:80/")); 

或者set a Proxy globally有:

WebProxy proxyObject = new WebProxy("http://webproxy:80/"); 
GlobalProxySelection.Select = proxyObject; 

configure it in Web.config

<configuration> 
    <system.net> 
    <defaultProxy> 
     <proxy 
     usesystemdefault="true" 
     proxyaddress="http://192.168.1.10:3128" 
     bypassonlocal="true" 
     /> 
     <bypasslist 
     <add address="[a-z]+\.contoso\.com" /> 
     </bypasslist> 
    </defaultProxy> 
    </system.net> 
</configuration> 
+1

完美。感谢您的答复。 – rudrvij