远程服务器(407)需要代理验证

时间:2016-03-24 14:34:22

标签: c# asp.net

我想连接到http网页,但每次进入catch并返回错误远程服务器(407)需要代理身份验证。为什么?我在另一个网站项目中使用了相同的代码,但它确实有效。

WebProxy wp = new WebProxy("**");
        wp.Credentials = new NetworkCredential("**", "**");
        StringBuilder sbXmlText = new StringBuilder();
        try
        {
            WebClient MyWebClient = new WebClient();
            MyWebClient.Proxy = wp;
            Stream TheStream = MyWebClient.OpenRead("http://www.bnr.ro/nbrfxrates10days.xml");
            StreamReader TheStreamReader = new StreamReader(TheStream);
            while (!TheStreamReader.EndOfStream)
                sbXmlText.Append((char)TheStreamReader.Read());
        }
        catch (Exception ex)
        {
            mail_send_bnr(ex.ToString(), "Error on connecting to bnr", "test");
        }

0 个答案:

没有答案