收到:无效的URI:无法解析主机名

时间:2014-08-17 17:35:33

标签: c# web uri invalidation

所以我用它来加载一个网站 :

WebClient webClient = new WebClient();
            webClient.Encoding = Encoding.UTF8;
            string str2 = webClient.DownloadString(url);
            if (Program.proxies.Count > 0)
            {
                string Address = Program.proxies[new Random().Next(0, Program.proxies.Count)];
                string[] strArray = Address.Split(':');
                if (strArray.Length > 2)
                    webClient.Proxy = (IWebProxy)new WebProxy(strArray[0] + ":" + strArray[1])
                    {
                        Credentials = (ICredentials)new NetworkCredential(strArray[2], strArray[3])
                    };
                else
                    webClient.Proxy = (IWebProxy)new WebProxy(Address);
            }
            return str2.Replace("'", "'");
        }
        catch (Exception ex1)
        {
            try
            {
                using (StreamWriter streamWriter = System.IO.File.AppendText("log.txt"))
                    streamWriter.WriteLine("[" + DateTime.Now.ToString() + "] " + ex1.Message);
                str1 = "";
            }
            catch (Exception ex2)
            {
                str1 = "";
            }
        }

我得到无效的URI:主机名无法在日志中解析,用于工作,我添加了一个Windows窗体,现在我不能让它像以前那样工作......而且像傻瓜一样。 ..我删除了我的旧项目

1 个答案:

答案 0 :(得分:0)

我发现这是我的代理列表文件中有空格