简体   繁体   English

如何在WCF客户端中设置HTTP代理的凭据

[英]How to set credentials for HTTP Proxy in WCF Client

I'm looking for the way to provide credentials (grammatically) for HTTP proxy that should be used to connect to service (Security Token Service), the proxy credentials differ from the credentials for the service. 我正在寻找为HTTP代理提供凭证(语法)的方法,该代理应该用于连接服务(安全令牌服务),代理凭证与服务的凭证不同。

I saw several posts here (it took me back to 2006-8) and the solution was by changing the default proxy 我在这里看到了几个帖子(它让我回到2006-8)并且解决方案是更改默认代理

WebProxy proxy = new WebProxy("http://myproxyserver",true);
proxy.Credentials = new NetworkCredential("username", "password");
WebRequest.DefaultWebProxy = proxy;

I think it is risky to change the global setting for all WebRequests from my assembly that performs a dedicated task. 我认为从执行专用任务的程序集更改所有WebRequest的全局设置是有风险的。

I'm wondering if in .NET 4.5 there is a better solution for this case. 我想知道在.NET 4.5中是否有更好的解决方案。

Similar questions: 类似的问题:

WCF Custom Http Proxy Authentication WCF自定义Http代理身份验证

How can I set an HTTP Proxy (WebProxy) on a WCF client-side Service proxy? 如何在WCF客户端服务代理上设置HTTP代理(WebProxy)?

不要设置默认代理,请为每个请求设置具有所需凭据的代理对象

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM