问题
Does anyone know what the side effects are of having a webrequest.proxy = null
in a HttpWebRequest?
MSDN (.NET Framework 4) says to use GlobalProxySelection.GetEmptyWebProxy()
when no proxy should be used. A blank IWebProxy
instance will be returned. Visual Studio says it's deprecated!!
Does the webrequest in both cases still work if the user's network requires proxy settings?
So, what is the correct approach and any known issues/side effects when a proxy is needed?
About the deprecated issue; Visual Studio says: Use null
instead
回答1:
No, there are no side effects.
VS is advising you correctly.
Does the webrequest in both cases still work if the user's network requires proxy settings?
An entirely different question. Your connection will most likely not work. Use WebRequest.DefaultWebProxy instead.
来源:https://stackoverflow.com/questions/7325572/c-webrequest-proxy-null-side-effects