title: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host in C#
body: <p>I have a code where I am sending the URL request and receiving the response and storing it as a String as</p>
  
  <pre><code>public String GenerateXML(String q)// Here 'q' is the URL 
  {
      // Generating the XML file for reference
      // Getting the response in XML format from the URL
  
      Debug.WriteLine("The Http URL after URL encoding :" + q);
      try
      {
          Uri signs1 = new Uri(q);
          //Debug.WriteLine("The Requested URL for getting the XML data :" + re);
  
          WebRequest request1 = WebRequest.Create(signs1);
  
          HttpWebResponse response1 = (HttpWebResponse)request1.GetResponse();
  
          //HttpWebResponse response1 = (HttpWebResponse)request1.GetResponse();
  
          Stream receiveStream = response1.GetResponseStream();
  
          StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8);
  
          String ab = readStream.ReadToEnd();// The mentioned error is showing up here.
          // Debug.WriteLine("The data :"+a);
          //XmlDocument content2 = new XmlDocument();
  
          // content2.LoadXml(ab);
  
          //  content2.Save("C:/Users/Administrator/Downloads/direct.xml");
          return ab;
      }
      catch (System.Net.WebException ex)
      {
          Debug.WriteLine("Exception caught :" + ex);
          return null;
      } 
  }
  </code></pre>
  
  <p>Why is the connection closed by the remote host?
  What are the possibilities of getting rid of the error or at least ignore the error and continue with other URL requests? I have included try and catch so as to escape any error and continue functioning with out any stop. Scoured the internet for solution but solutions to this particular problem is pretty much specific. Please any help is appreciated.
  Thanks in advance.</p>