I am wondering what the main differences are between DefaultWebProxy and GetSystemWebProxy(). There’re some descriptions on MSDN, but I still feel I need a bit more details to have a better understanding.
Also, let’s say I have following options for proxy configuration on my C# winform application
- Auto-detect proxy settings
- Use system default settings
- No proxy
Then which method goes to which option? Is it right to say that Auto-detect proxy somewhat equals Use system default settings?
Per the MSDN article for
WebRequest.DefaultWebProxy, this property will provide the proxy information specified in theapp.configfile. It looks like the .NET Framework v3.5 MSDN Article is missing this specific detail.As far as
WebRequest.GetSystemWebProxy()goes, the MSDN article for it states that this method will provide the system-wide configured proxy (Control Panel > Internet Options).This is how I would suggest you implement the three options outlined:
WebRequest.GetSystemWebProxy()(I wouldn’t recommend this approach); orWebRequest.GetSystemWebProxy();WebRequest.DefaultWebProxyand theWebRequest.Proxyproperties;Edit: If no proxy is configured in app.config
WebRequest.DefaultWebRequestis almost the same asWebRequest.GetSystemWebProxy()(at least for .NET 4.5). The difference is thatWebRequest.GetSystemWebProxy()will run the PAC script (if any) for proxy definition.Thanks to Gabrielius and to 23W for the comments below.