ServiceStack HttpUtils +代理服务器

时间:2017-03-15 19:11:12

标签: servicestack servicestack-text

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

由于 rudrvij

1 个答案:

答案 0 :(得分:1)

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>