title: webBrowser Cookies and Form Submitting
body: <p>I want to navigate to a website using pre-defined cookies,
  Add some text to couple of <code>input type="text"</code> and submit the form using the submit button.
  I know it can be done, but I can't find how.</p>
  
  <p>I already tried to send the POST data to the page, but I have to click the button for the action to be executed.
  Here is my code:</p>
  
  <pre><code>        static String readHtmlPage(string url)
          {
  
          //setup some variables
  
          String username = "demo";
          String password = "password";
          String firstname = "John";
          String lastname = "Smith";
  
          //setup some variables end
  
          String result = "";
          String strPost = "username=" + username + "&amp;password=" + password + "&amp;firstname=" + firstname + "&amp;lastname=" + lastname;
          StreamWriter myWriter = null;
  
          HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
          objRequest.Headers["Cookie"] = "sid=0";
          objRequest.Headers["Cookie"] = "username=0";
          objRequest.Method = "POST";
          objRequest.ContentLength = strPost.Length;
          objRequest.ContentType = "application/x-www-form-urlencoded";
  
          try
          {
              myWriter = new StreamWriter(objRequest.GetRequestStream());
              myWriter.Write(strPost);
          }
          catch (Exception e)
          {
              return e.Message;
          }
          finally
          {
              myWriter.Close();
          }
  
          HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
          using (StreamReader sr =
             new StreamReader(objResponse.GetResponseStream()))
          {
              result = sr.ReadToEnd();
  
              // Close and clean up the StreamReader
              sr.Close();
          }
          return result;
      }
  
  
      static void Main(string[] args)
      {
  
          Console.Write(readHtmlPage("http://www.ggogle.com/"));
      }
  </code></pre>