Using GeoCode with C#
use the HttpClient class which is often used with Asp.Net Web Api or Asp.Net 5.0.
You have also a http state codes for free, asyn/await programming model and exception handling with HttpClient is easy as pie
|
var address = "paris, france";
var requestUri = string.Format("http://maps.googleapis.com/maps/api/geocode/xml?address={0}&sensor=false", Uri.EscapeDataString(address));
using (var client = new HttpClient())
{
var request = await client.GetAsync(requestUri);
var content = await request.Content.ReadAsStringAsync();
var xmlDocument = XDocument.Parse(content);
}
No comments:
Post a Comment