C#: WebRequest proxy = null side effects

為{幸葍}努か 提交于 2021-01-27 12:56:36

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!