Web异常未被用户代码处理。无法连接到远程服务器

时间:2016-04-18 09:05:57

标签: asp.net

我可以从浏览器中点击“http://api.openweathermap.org/data/2.5/forecast/daily?q=Bangalore”。

但是当我试图从asp.net调用同样的错误时。代码如下。

    string url = "http://api.openweathermap.org/data/2.5/forecast/daily?q=Bangalore";
    using (WebClient client = new WebClient())
    {
        string json = client.DownloadString(url);

        WeatherInfo weatherInfo = (new JavaScriptSerializer()).Deserialize<WeatherInfo>(json);
    }

错误是 - “无法连接到远程服务器”。

可能是什么原因?

0 个答案:

没有答案