本文介绍了使用API​​的WebRespons中出现[C#]错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在使用此网站的MacVendorLookUp API: []



错误:

System.dll中发生了'System.Net.WebException'类型的未处理异常



附加信息:远程服务器返回错误(407)需要代理验证。



错误代码:

I am using a MacVendorLookUp API from this site: http://www.macvendorlookup.com[^]

Error:
"An unhandled exception of type 'System.Net.WebException' occurred in System.dll

Additional information: The remote server returned an error (407) Proxy Authentication Required."

Error in code:

WebResponse response = request.GetResponse();





完整的C#事件代码:





Full C# event code:

private void findvendorButton_Click(object sender, EventArgs e)
        {
            string cell = "";
            System.IO.StreamReader reader;
            WebRequest request = WebRequest.Create("http://www.macvendorlookup.com/api/v2/{" + macaddressTextBox.Text + "}");
            request.Timeout = 120000;
            WebResponse response = request.GetResponse();
            reader = new System.IO.StreamReader(response.GetResponseStream());
            string get = reader.ReadToEnd();
            MatchCollection m1 = Regex.Matches(get, @"(company)(.*?)(}])", RegexOptions.Singleline);
            foreach (Match m in m1)
            {
                cell = m.Groups[0].Value;
            }
            vendorTextBox.Text = cell.Trim().Split('\"')[2].ToString();
        }





任何人都知道我能做些什么来防止这个错误?

有时我得到错误,有时候我没有...我不明白..



Anyone knows what i can do to prevent this error?
Sometimes i get the error, and sometimes i don't.. I don't understand..

推荐答案


这篇关于使用API​​的WebRespons中出现[C#]错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-16 03:52