Reputation: 651
I am developing a windows application. It calls a webservice. But some of my clients use a proxy. For proxy-using clients I want to show a message box and redirect to application settings WinForm for proxy credential ınfo.
So how can detect a client is using proxy? (I am using C#)
Upvotes: 0
Views: 1726
Reputation: 1097
Just check by WebRequest.DefaultWebProxy
string sampleURL = "http://proxy.example.com";
bool useProxy = !string.Equals(System.Net.WebRequest.DefaultWebProxy.GetProxy(new Uri(sampleURL)), sampleURL);
Console.WriteLine( useProxy ? "Yes" : "No");
Or by simple cast check:
if (System.Net.WebRequest.DefaultWebProxy as System.Net.WebProxy != null) {}
Upvotes: 3