Do a web request using System.Net classes, HttpWebRequest or WebClient. For example:
If the first request takes more than 4 seconds and you think is too much time for your application, then the following information may interest you.
One way to skip this detection is by setting the proxy settings yourself, either by code or by using a configuration file like this:
WinHttpGetProxyForUrl can be used for detecting the proxy for an URL and the function WinHttpGetIEProxyConfigForCurrentUser is useful if you want to read the proxy configuration from Internet Explorer. In this example I won’t do the IE proxy configuration reading just to keep it simple.
WinHttpGetProxyForUrl return a list of proxies to use. That list may look like a list of IP address separated by colons. In the example below I split that list and pre-append the http:// suffix if needed so it can became a valid URL. This example just picks the first proxy address and uses it. You can later on add logic to try multiple proxies if the request fails, just remember that once you use a HttpWebRequest object, you cannot re-use it, you need to create a new one and also keep the tracking of the all the timeout so you don’t end waiting 1 hour before timeout. If you use WebClient, you can override the method GetWebResponse and set the proxy there, just don’t eat the WebException exceptions that have a Status equals WebExceptionStatus.ProtocolError since that is actually a valid response.
Using normal System.Net proxy detection I get the output:
Using WinHttp.dll I get:
Here you have: