0
public ActionResult GetGeoLocation(string address)
{
    var uri = string.Format(
        "http://maps.google.com/maps/api/geocode/json?address={0}&sensor=false",
        HttpUtility.UrlEncode(address)
        );

    var request = (HttpWebRequest)HttpWebRequest.Create(uri);
    var response = (HttpWebResponse)request.GetResponse(); 

    return Json(response);
}

This code seems to call out just fine, but it's not returning the proper results? I must be missing something?

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Mark
  • 2,543
  • 6
  • 33
  • 44

1 Answers1

1

You are not reading the response data.

Use GetResponseStream to get the stream containing the body of the response.

var responseStream = response.GetResponseStream();

// read from responseStream
Oded
  • 489,969
  • 99
  • 883
  • 1,009
  • that doesn't seem to get me the right response either. I'm trying to find all the data I would get if I used this http://maps.google.com/maps/api/geocode/json?address=8793+s.+carr+way&sensor=false That returns the JSON I need. – Mark Oct 21 '11 at 19:59
  • @Mark - http://stackoverflow.com/questions/137285/what-is-the-best-way-to-read-getresponsestream/137300#137300 – Oded Oct 21 '11 at 20:09