0

Is there any default proxy setup for all outgoing connection for a C# application?

I am developing a small program that use third party C# libraries. there are two libraries from different vendors. Both take data from Internet. My program should connect trough a proxy, but the server shouldn't.

I need to set a proxy for the program only. I try to use WebRequest.DefaultWebProxy. For one DLL it works, but for another one it doesn't. The working DLL uses the 443 port, the non-working DLL uses custom ports.

Is there any option to set proxies for C# applications?

Quality Catalyst
  • 6,531
  • 8
  • 38
  • 62
  • "second uses custom ports" are you sure it is even using HTTP at all? – Alexei Levenkov Jun 10 '16 at 06:32
  • got any firewalls ? for example, where I work, port 80 and 443 would work through the proxy, but non standard ports dont. – BugFinder Jun 10 '16 at 06:51
  • I suppose it is not HTTP, it is probably Sockets. Can I use DefaultProxy with other protocols, or can I use something like DefaultProxy with other protocols? The second dll still connect to remote resourse, but ignore WebRequest.DefaultWebProxy. First one connect through proxy. For now proxy open for all ports. – Мокеров Виктор Jun 10 '16 at 11:38

1 Answers1

-1

You can try this:

System.Net.WebRequest.DefaultWebProxy.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;

From here:

This will force the DefaultWebProxy to use default credentials, similar effect as done through UseDefaultCredentials = true.

Hence all newly created WebRequest instances will use default proxy which has been configured to use proxy's default credentials.

Of course you could be experiencing another issue i.e. the none default port is being blocked by the proxy or a firewall. You could try a telnet to verify that the port is accessible.

Community
  • 1
  • 1
majita
  • 1,278
  • 14
  • 24