Mark Irvin
Mark Irvin

Reputation: 840

How do I write c# code that detects a proxy

I need to be able to detect if navigating to a particular URL requires hitting a proxy server. Some ideas as well as c# (or Java) code would be appreciated.

Thanks for your time DTM

Upvotes: 1

Views: 368

Answers (1)

Arnout
Arnout

Reputation: 2790

WebRequest.DefaultWebProxy gives you access to the proxy, and then you can feed your URL to GetProxy() and see what it returns:

Console.WriteLine(WebRequest.DefaultWebProxy.GetProxy(new Uri("http://stackoverflow.com")));

Upvotes: 1

Related Questions