title: HtmlDocument.LoadHtml from WebResponse?
body: <p>I try to extract image from a posted link and the first check I do is to see if the link is to a plain image like this : </p>
  
  <pre><code>    HttpWebRequest request;
      WebResponse webresponse;
  
      request = (HttpWebRequest)HttpWebRequest.Create(url);
  
       webresponse = request.GetResponse();
       if (webresponse.ContentType.StartsWith("image/"))
         ...
  </code></pre>
  
  <p>If this is not found I want to go on with the HTML Agility Pack but to be able to do that I need to run : </p>
  
  <pre><code>HtmlDocument doc;
  reader = new StreamReader(webresponse.GetResponseStream());
  doc.LoadHtml(reader.ReadToEnd());
  </code></pre>
  
  <p>The problem is that LoadHtml will not find any source even when Im sure that there is HTML code in the response. I suspect that the formation of the HTML is not in correct format?</p>
  
  <p>Here is part of what the ReadToEnd will generate : </p>
  
  <pre><code>    &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  
      &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="sv" lang="sv"&gt;
      &lt;head&gt;&lt;title&gt;
          X - Eclipse - 2011
      &lt;/title&gt;
  
          &lt;!--[if lt IE 7]&gt;
          &lt;script defer type="text/javascript" src="../javascript/pngfix.js"&gt;&lt;/script&gt;
          &lt;![endif]--&gt;
          &lt;!--&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;--&gt;
  
          &lt;meta http-equiv="Content-type" content="text/html; charset=iso-8859-1" /&gt;&lt;link href="../../../App_Themes/X/mainStyleSheet.css" type="text/css" rel="stylesheet" /&gt;&lt;meta name="author" content="" /&gt;&lt;meta name="copyright" content="X.net" /&gt;&lt;meta name="description" content="Välkommen in till ett av Sveriges största Xcommunity." /&gt;&lt;meta name="keywords" content="X, rollspel, boardgamegeek, boardgame, X.net, X.net, community, Jimmy, Nilsson, schack, risk, puerto rico" /&gt;&lt;script language="javascript" type="text/javascript" src="/sites/X/javascript/common.js"&gt;&lt;/script&gt;&lt;script language="javascript" type="text/javascript" src="/sites/X/javascript/ajaxHandler.js"&gt;&lt;/script&gt;&lt;script language="javascript" type="text/javascript" src="/javascript/jquery.js"&gt;&lt;/script&gt;&lt;link rel="shortcut icon" href="/App_Themes/X/Images/common/browserIcon/favicon.ico" /&gt;&lt;link rel="icon" href="/App_Themes/X/Images/common/browserIcon/animated_favicon1.gif" type="image/gif" /&gt;&lt;/head&gt;
      &lt;body&gt;
          &lt;div id="topBack"&gt;
          &lt;div id="siteContainer"&gt;
          &lt;form method="post" action="game.aspx?gameId=72125" id="aspnetForm" enctype="multipart/form-data"&gt;
  
  &lt;input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDw....
  </code></pre>
  
  <p>I can see that the string contains some newline(\r\n) commands if that matters?</p>
  
  <p>My goal is simple to avoid downloading the webpage more then one time, else I could use the <code>WebClient.DownloadString(url);</code> to download it in a format that I know works.</p>