我可以从浏览器中点击“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);
}
错误是 - “无法连接到远程服务器”。
可能是什么原因?