title: C# Downloading website into string using C# WebClient or HttpWebRequest
body: <p>I am trying to download the contents of a website. However for a certain webpage the string returned contains jumbled data, containing many � characters.</p>
  
  <p>Here is the code I was originally using.</p>
  
  <pre><code>HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url);
  req.Method = "GET";
  req.UserAgent = "Mozilla/5.0 (Windows; U; MSIE 9.0; WIndows NT 9.0; en-US))";
  string source;
  using (StreamReader reader = new StreamReader(req.GetResponse().GetResponseStream()))
  {
      source = reader.ReadToEnd();
  }
  HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
  doc.LoadHtml(source);
  </code></pre>
  
  <p>I also tried alternate implementations with WebClient, but still the same result:</p>
  
  <pre><code>HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
  using (WebClient client = new WebClient())
  using (var read = client.OpenRead(url))
  {
      doc.Load(read, true);
  }
  </code></pre>
  
  <p>From searching I guess this might be an issue with Encoding, so I tried both the solutions posted below but still cannot get this to work.</p>
  
  <ul>
  <li><a href="http://blogs.msdn.com/b/feroze_daud/archive/2004/03/30/104440.aspx">http://blogs.msdn.com/b/feroze_daud/archive/2004/03/30/104440.aspx</a></li>
  <li><a href="http://bytes.com/topic/c-sharp/answers/653250-webclient-encoding">http://bytes.com/topic/c-sharp/answers/653250-webclient-encoding</a></li>
  </ul>
  
  <p>The offending site that I cannot seem to download is the United_States article on the english version of WikiPedia (en . wikipedia . org / wiki / United_States).
  Although I have tried a number of other wikipedia articles and have not seen this issue.</p>