ServiceStack HttpUtils + 代理服务器

ServiceStack HttpUtils + Proxy Server

我正在使用 ServiceStack HttpUtils 连接到第三方 REST API。 请求时如何传入Proxy Server和Proxy Port?

谢谢 鲁德维

HTTP Utils is a wrapper over .NET's HttpWebRequest so you can use the same functionality to specify a 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>