以下代码适用于我:
var webProxy = WebProxy.GetDefaultProxy();
webProxy.UseDefaultCredentials = true;
WebRequest.DefaultWebProxy = webProxy;
Run Code Online (Sandbox Code Playgroud)
不幸的是,WebProxy.GetDefaultProxy()
已被弃用.我还应该做什么?
(在部署中不允许使用app.config设置defaultProxy设置)