I'm trying to used Yahoo's PlaceFinder API to get longitude and latitude for a postcode. Everything works fine on my local machine but when I upload it to my production server I get a connection refused error from Yahoo. I've copied my code below:
Dictionary<string, decimal> GetYahooGeoCode(string postcode)
{
string url = "http://where.yahooapis.com/geocode?flags=J&appid=[My_App_ID]&location=";
decimal latitude = 0;
decimal longitude = 0;
try
{
dynamic yahooResults = new Uri(url + postcode).GetDynamicJsonObject();
foreach (var result in yahooResults.ResultSet.Results)
{
latitude = (decimal)result.latitude;
longitude = (decimal)result.longitude;
}
Dictionary<string, decimal> geoCode = new Dictionary<string, decimal>();
geoCode.Add("latitude", latitude);
geoCode.Add("longitude", longitude);
return geoCode;
}
catch (Exception ex)
{
Log4NetLogger logger = new Log4NetLogger();
logger.Error(ex);
return null;
}
}
The error I'm getting is: No connection could be made because the target machine actively refused it. Does anyone have any ideas on this? I have done a lot of searching and can't seem to find any information on this problem. I don't know if this makes any difference but my production server is a dedicated Cloud server. Any help would be appreciated.
I try to solve your problem here my solition:
Check your web.config:
And my code (GetDynamicJsonObject() not parsed the response):
Check place finder yahoo api parameters here http://developer.yahoo.com/geo/placefinder/guide/requests.html#base-uri