title: Stop webclient from escaping strings
body: <p>I want to use the Google Maps API to geocode/reverse-geocode coordinates/addresses. To do this, I use an instance of C#'s webclient class.</p>
  
  <pre><code>static string gMapsUrl= "http://maps.googleapis.com/maps/api/geocode/xml?address=  {0}&amp;sensor=false";
  public static List&lt;Location&gt; RetrieveCoordinate(string address)
  {
      string requestUri = string.Format(gMapsUrl, address);
      string result = string.Empty;
  
      using (var client = new WebClient())
      {
          client.Encoding = System.Text.Encoding.UTF8;
          result = client.DownloadString(requestUri);
      }
  ....
  }
  </code></pre>
  
  <p>This usually works, however lets say I want to reverse-geocode the address "Götznerstraße". If I do this manually in a browser, everything works fine, the URL of the request would be </p>
  
  <pre><code>http://maps.googleapis.com/maps/api/geocode/xml?address=götznerstraße&amp;sensor=false
  </code></pre>
  
  <p>The eventual request from my program however looks like this</p>
  
  <pre><code>GET /maps/api/geocode/xml?address=G%C3%B6tznerstra%C3%9Fe&amp;sensor=false HTTP/1.1 
  </code></pre>
  
  <p>This leads to Google finding no matches. To me it appears as if the webclient escapes the umlaute somewhere, which prevents me from getting results. Is there a way to stop the webclient from doing this, or make Google unescape the string again?</p>
  
  <p>EDIT:
  I solved it, after comparing the request from the browser and my program, I realized that my browser was sending some additional headers. The changed implementation looks like this</p>
  
  <pre><code>using (var client = new WebClient())
  {
      client.Headers.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
      client.Headers.Add("Accept-Encoding", "gzip,deflate,sdch");
      client.Headers.Add("Accept-Language", "de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4");
      client.Encoding = System.Text.Encoding.UTF8;
      result = client.DownloadString(requestUri);
  }
  </code></pre>
  
  <p>Thanks a lot to everyone that helped!</p>