title: Login to web form through C#
body: <p>I know that there are TONS of questions asking the very same thing that I am asking on this very site, but I cannot get my login to work correctly.</p>
  
  <p>The site that I am attempting to log into is located <a href="http://isitclean.net/index.php" rel="nofollow">here</a></p>
  
  <p>The code that I am using to do so is:</p>
  
  <pre><code>        private void wb_scanFile_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
      {
          if (wb_scanFile.Url.ToString() == "http://isitclean.net/index.php")
          {
              string formUrl = "http://isitclean.net/index.php"; // NOTE: This is the URL the form POSTs to, not the URL of the form (you can find this in the "action" attribute of the HTML's form tag
              string formParams = string.Format("username={0}&amp;password={1}", "mine", "mypass");
              string cookieHeader;
              WebRequest req = WebRequest.Create(formUrl);
              req.ContentType = "application/x-www-form-urlencoded";
              req.Method = "POST";
              byte[] bytes = Encoding.ASCII.GetBytes(formParams);
              req.ContentLength = bytes.Length;
              using (Stream os = req.GetRequestStream())
              {
                  os.Write(bytes, 0, bytes.Length);
              }
              WebResponse resp = req.GetResponse();
              cookieHeader = resp.Headers["Set-cookie"];
          }
      }
  </code></pre>
  
  <p>What is the problem here? I don't understand why it's not filling in the text box correctly.</p>