带凭据的 C# WebProxy

C# WebProxy with credentials

我想通过具有身份验证的代理发出请求,但出现错误:成功。 如果我不使用代理,请求就可以正常工作。代理数据是正确的,我已经用 curl 测试过了。 请求仅使用 https 失败。

var p = new WebProxy(ProxyUrl, ProxyPort)
{
    Credentials = new NetworkCredential(ProxyUsername, ProxyPassword)
};

var req = WebRequest.Create("https://api.ipify.org/?format=json");
req.Proxy = p;
req.GetResponse();

错误日志:

Unhandled Exception:
System.Net.WebException: Error: Success
  at System.Net.HttpWebRequest.EndGetResponse (System.IAsyncResult asyncResult) [0x00064] in <bd46d4d4f7964dfa9beea098499ab597>:0 
  at System.Net.HttpWebRequest.GetResponse () [0x0000e] in <bd46d4d4f7964dfa9beea098499ab597>:0 

...

Process finished with exit code 1.

控制台应用.net v4.6.1

问题出在Mono中,我的版本是4.6.2。 所以我从 https://www.mono-project.com/download/stable/ 安装了最新版本 (5.20.1.19),问题消失了。