1

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?

Community
  • 1
  • 1
Zaky
  • 369
  • 6
  • 21

1 Answers1

0

Don't set default proxy, set proxy object with desired credentials per request

Oleg Bogdanov
  • 1,712
  • 13
  • 19
  • I can set proxy via WSHttpBinding, but there is no way to set credentials. – Zaky Nov 08 '16 at 16:37
  • Would WSHttpBinding.Security.Transport.ProxyCredentialType help? – Oleg Bogdanov Nov 08 '16 at 16:51
  • No, because it only has Credential Type but not the credentials itself. It assumes (as I understand and as I read through similar questions) that proxy credentials and client credentials are the same. That is not my case. – Zaky Nov 09 '16 at 06:18