I've read through pretty much all the documentation I can find but I'm yet to find a simple working example of how to get IE's default proxy settings using DefaultWebProxy()
.
This code seems to compile and work but how do I then go ahead and get the proxy URI as a string?
HttpWebRequest webRequest =
(HttpWebRequest)HttpWebRequest.Create("http://www.google.com");
if (WebRequest.DefaultWebProxy != null)
{
webRequest.Proxy = WebRequest.DefaultWebProxy;
}
EDIT:
Since submitting this question I have found that one or many proxies can be set for different destinations or bypassed (perhaps for local intranet destinations). That's why you need to specify a URI to GetProxy()
. It needs to know which destination to get the proxy for. If "Automatically Detect Settings" is set in Internet Options the browser will look for a PAC file on your local domain. The PAC file contains a Javascript function which determines the proxy address for a given destination.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…