简体   繁体   中英

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.

I saw several posts here (it took me back to 2006-8) and the solution was by changing the default proxy

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.

I'm wondering if in .NET 4.5 there is a better solution for this case.

Similar questions:

WCF Custom Http Proxy Authentication

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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