问题描述
有人知道在HttpWebRequest中使用 webrequest.proxy = null
有什么副作用吗?
Does anyone know what the side effects are of having a webrequest.proxy = null
in a HttpWebRequest?
MSDN(.NET Framework 4)表示当不使用任何代理时,请使用 GlobalProxySelection.GetEmptyWebProxy()
.一个空白的 IWebProxy
实例将被返回.Visual Studio表示已弃用!!
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!!
如果用户的网络需要代理设置,两种情况下的webrequest是否仍然有效?
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?
关于已过时的问题;Visual Studio说:改为使用 null
About the deprecated issue; Visual Studio says: Use null
instead
推荐答案
不,没有副作用.
VS为您提供了正确的建议.
No, there are no side effects.
VS is advising you correctly.
一个完全不同的问题.您的连接很有可能不起作用.使用 WebRequest.DefaultWebProxy
代替.
An entirely different question. Your connection will most likely not work. Use WebRequest.DefaultWebProxy
instead.
这篇关于C#:WebRequest代理=空副作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!