title: How can I use HttpClient in my .NET Framework 4.5 app/site?
body: <p>Based on the answer here: <a href="https://stackoverflow.com/questions/16470458/how-can-i-retrieve-and-parse-just-the-html-returned-from-an-url">How can I retrieve and parse just the html returned from an URL?</a></p>
  
  <p>...I'm trying to begin by adding code based on that found here: <a href="http://msdn.microsoft.com/en-us/library/system.net.http.httpclient.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/system.net.http.httpclient.aspx</a></p>
  
  <p>...namely by adding this to \App_Code\Functions.cshtml:</p>
  
  <pre><code>@functions
  {
      public static string GetUrlHtml(string dynamicUrl)
      {
          HttpClient client = new HttpClient();
          string body = await client.GetStringAsync(dynamicUrl);
      // parse it using HTML Agility Pack? (http://htmlagilitypack.codeplex.com/)
      }
  }
  </code></pre>
  
  <p>HttpClient is not recognized, and does not afford a "resolve" context menu item. Intellisense does not offer me a "Http" after entering:</p>
  
  <pre><code>@using System.Net.
  </code></pre>
  
  <p>Is HttpClient really unavailable to me? If so, what can I have as a consolation prize? Is my best option to use WebClient like so:</p>
  
  <pre><code>WebClient wc = new WebClient();
  string body = wc.DownloadString(dynamicUrl);
  // parse it with html agility pack
  </code></pre>
  
  <p>...or, as shown at <a href="https://web.archive.org/web/20211020001935/https://www.4guysfromrolla.com/articles/011211-1.aspx#postadlink" rel="nofollow noreferrer">https://web.archive.org/web/20211020001935/https://www.4guysfromrolla.com/articles/011211-1.aspx#postadlink</a>, I can use the webGet class from the HTML Agility Pack:</p>
  
  <pre><code>var webGet = new HtmlWeb();
  var document = webGet.Load(dynamicUrl);
  </code></pre>
  
  <p>Does anybody have any supportable opinions on which option is the best?</p>