title: Submitting item within a form
body: <p>[Edited 10/01/18 to give more background on the code. This version present the complete code used] </p>
  
  <p>I am struggling a bit with a form submitting using AngleSharp.</p>
  
  <p>I use AngleSharp to Scrap this website for <a href="http://www.gatherproxy.com/proxylist/anonymity/?t=Elite" rel="nofollow noreferrer">Proxies</a> addresses. Basically I open the website with AngleSharp and a IBrowsingContext (Page in my code)</p>
  
  <p>I then SubmitAsync the Forms[0] to have the full list of proxies (see the website link to understand what I mean) and read the different proxies there [this part is not presented here].</p>
  
  <p>It then got more complicated when I want to navigate within the different pages (usually around 60 pages with a navigating bar at the bottom, i.e. Forms<a href="http://www.gatherproxy.com/proxylist/anonymity/?t=Elite" rel="nofollow noreferrer">1</a> in the Page).</p>
  
  <p>As advised by Florian Rappl I turned on the ressource loading based on an example he gave (<a href="https://github.com/AngleSharp/AngleSharp.Samples/blob/master/AngleSharp.Samples.App/ViewModels/MainViewModel.cs" rel="nofollow noreferrer">see here</a>). In the code posted below I commented with the memory usage as it seems the ressource loading loop download something with the memory usage skyrocketting. For comparison I provided the memory usage without the ressource loading. This is a fully workable code for a console app.</p>
  
  <pre><code>static void Main(string[] args)
      {
          ASTester().GetAwaiter().GetResult();
          Console.ReadKey();
      }
  </code></pre>
  
  <p>.</p>
  
  <pre><code>static async Task ASTester()
      {
          var Handler = new HttpClientHandler()
          {
              PreAuthenticate = true,
              UseDefaultCredentials = false,
          };
  
          var Client = new HttpClient(Handler);
          Client.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36");
  
          var Requester = new HttpClientRequester(Client);
  
          var Configuration = AngleSharp.Configuration.Default.WithDefaultLoader(setup =&gt;
          {
              setup.IsResourceLoadingEnabled = true;
          }, requesters: new[] { Requester }).WithJavaScript().WithCss();
          var Page = BrowsingContext.New(Configuration);
  
  
          /*At this point : 
           *              Mem usage : ~15 MB
           */
  
          /*Open the page with the proxy list 
           *      with setup.IsResourceLoadingEnabled = true; 
           *              Mem usage : ~80 MB
           *      without
           *              Mem usage : ~35 MB
           */
          await Page.OpenAsync("http://www.gatherproxy.com/proxylist/anonymity/?t=Elite");
  
          /*Submit the first form (id = 0) which will activate the bar to navigate within the different pages
           *      with setup.IsResourceLoadingEnabled = true; 
           *              Mem usage : 300 MB
           *      without
           *              Mem usage : ~50 MB
           */
          await Page.Active.Forms[0].SubmitAsync();
  
          /*Activate the script to go to page 2
           *      with setup.IsResourceLoadingEnabled = true; 
           *              Mem usage : 1.5 GB
           *      without
           *              Mem usage : &gt;&gt; Exception
           */
          Page.Active.ExecuteScript("gp.pageClick(2);");
  
          //Giving time for the script to execute
          Thread.Sleep(40000);
  
      }
  </code></pre>
  
  <p>Half of the time the script execution throw an exception. For the rest the Page.Active evaluation is <code>'((AngleSharp.Dom.Document)((AngleSharp.BrowsingContext)Page).Active).ActiveElement' threw an exception of type 'System.NullReferenceException'</code></p>