title: request.getResponse() is getting error
body: <p>This is my code which is returning the expected output on my friend's PC, but not on mine.</p>
  
  <p>We are both working with Visual Studio 2017 Community:</p>
  
  <p><a href="https://i.stack.imgur.com/KwlYT.jpg" rel="nofollow noreferrer">enter image description here</a></p>
  
  <p>This is the code that will return latitude and longitude of the entered address:</p>
  
  <p>[enter image description here][2]</p>
  
  <p>The first time it works fine but after that its throwing (403 forbidden error !!! / mainly problem is on the request.getResponse()) </p>
  
  <pre><code>    private static String[] x = new String[3];
  
      public static String[] GetFirstLastName(string address)
      {
          try { 
          string url = "http://maps.google.com/maps/api/geocode/xml?address=" + address + "&amp;sensor=false";
  
          WebRequest request = WebRequest.Create(url);
          // request.UseDefaultCredentials = true;
          // request.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
          // request.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
          using (WebResponse response = (HttpWebResponse)request.GetResponse())
          {
              using (var reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
              {
                  var ds = new DataSet("Employee");
                  ds.ReadXml(reader);
  
                  DataRow dr = null;
  
                  var dt = new DataTable("Employee");
                  dt.Columns.AddRange(new DataColumn[2]
                      {
                          new DataColumn("Latitude", typeof (string)),
                          new DataColumn("Longitude", typeof (string))
                      });
  
                  int i = 0;
  
                  try
                  {
                      foreach (DataRow row in ds.Tables["result"].Rows)
                      {
                      }
                  }
                  catch (Exception e)
                  {
                     Console.WriteLine(e.ToString());
                     return x;
                  }
  
                  foreach (DataRow row in ds.Tables["result"].Rows)
                  {
                      if (i == 0)
                      {
                          string geometry_id = ds.Tables["geometry"].Select("result_id = " + row["result_id"])[0]["geometry_id"].ToString();
  
                          dr = ds.Tables["location"].Select("geometry_id = " + geometry_id)[0];
  
                          dt.Rows.Add(dr["lat"], dr["lng"]);
  
                          //  Console.WriteLine(dr["lat"].ToString() + " " + dr["lng"].ToString());
                          i = 1;
                          break;
                      }
                  }
  
                  x[0] = dr["lat"].ToString();
                  x[1] = dr["lng"].ToString();
  
                  reader.Close();
              }
  
              // request.Timeout = 0;
              // request.Abort();
              response.Close();
              return x;
          }
      }
      catch(Exception e)
      {
          Console.WriteLine(e);
          x[0] = "";
          x[1] = "";
          return x;
      }
  }
  
  public static String[] GetFirstLastName1(string address)
  {
          try
          {
              string url = "http://maps.google.com/maps/api/geocode/xml?address=" + address + "&amp;sensor=false";
              WebRequest request = WebRequest.Create(url);
              //  request.UseDefaultCredentials = true;
              // request.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
              //   request.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
              using (WebResponse response = request.GetResponse())
              {
                  using (var reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
                  {
                      var ds = new DataSet("Employee");
                      ds.ReadXml(reader);
  
                      DataRow dr = null;
  
                      var dt = new DataTable("Employee");
                      dt.Columns.AddRange(new DataColumn[2]
                      {
                  new DataColumn("Latitude", typeof (string)),
                  new DataColumn("Longitude", typeof (string))
                      });
  
                      int i = 0;
  
                      try
                      {
                          foreach (DataRow row in ds.Tables["result"].Rows)
                          {
  
                          }
  
  
                      }
                      catch (Exception e)
                      {
                          Console.WriteLine(e.ToString());
  
                          return x;
                      }
  
                      foreach (DataRow row in ds.Tables["result"].Rows)
                      {
                          if (i == 0)
                          {
                              string geometry_id = ds.Tables["geometry"].Select("result_id = " + row["result_id"])[0]["geometry_id"].ToString();
  
                              dr = ds.Tables["location"].Select("geometry_id = " + geometry_id)[0];
  
                              dt.Rows.Add(dr["lat"], dr["lng"]);
  
                              //  Console.WriteLine(dr["lat"].ToString() + " " + dr["lng"].ToString());
                              i = 1;
                              break;
                          }
                      }
                      x[0] = dr["lat"].ToString();
                      x[1] = dr["lng"].ToString();
                      reader.Close();
                  }
                  //// request.Timeout = 0;
                  ///   request.Abort();
                  response.Close();
                  return x;
              }
          }
          catch (Exception e)
          {
              Console.WriteLine(e);
              x[0] = "";
              x[1] = "";
              return x;
          }
  
      }
      static void Main(string[] args)
      {
  
          int i = 0;
  
          for (;;)
          {
              String x = Console.ReadLine();
              if (i == 0)
              {
                  String[] y = GetFirstLastName(x);
  
                  Console.WriteLine(y[0] + " " + y[1]);
              }
              else
              {
                  String[] y = GetFirstLastName1(x);
  
                  Console.WriteLine(y[0] + " " + y[1]);
              }
  
              i++;
          }
          //Console.ReadKey();
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>/*(Same Code above)</p>
  
  <pre><code>enter code here
  </code></pre>
  
  <p>///My Friends Output
     /// My Output
    [2]: <a href="https://i.stack.imgur.com/qeDcz.png" rel="nofollow noreferrer">https://i.stack.imgur.com/qeDcz.png</a> */</p>