title: post the form data to server in C# console application
body: <p>I am trying to post the data from this form internally using C# console application. But i dont understand why its not working. Below is the form inside the body tag of html page.   </p>
  
  <pre><code>&lt;form method="POST" name="frogs_simple_vmf" action="frog_simple.php"&gt;
  
              &lt;table BORDER="0" cellpadding="5" cellspacing="0" border="0" class="tbl"&gt;       
  
                &lt;tr&gt;
                      &lt;td&gt;
                         &lt;select name='from' onchange='check_ns2(this.form)'&gt;
                            &lt;option value='Sub1'&gt;Sub1&lt;/option&gt;
                    &lt;option value='Sub2'&gt;Sub2&lt;/option&gt;
                    &lt;option value='Sub3'&gt;Sub3&lt;/option&gt;              
                            &lt;option value='Sub4'&gt;Sub4&lt;/option&gt;              
                         &lt;/select&gt;
                         &amp;nbsp
                         &lt;input type='text' name='spec_id' size='30'&gt;
                      &lt;/td&gt;
                    &lt;/tr&gt;
                  &lt;tr&gt;
                  &lt;td&gt;
                  &lt;table WIDTH="400" BORDER="0" cellpadding="0" cellspacing="0" &gt;     
                  &lt;tr&gt;
                              &lt;td WIDTH="150"&gt;&lt;b&gt;&lt;a href="javascript:popup('../help/help_avp_light_eu.htm#Run_option', '500', '300');" class="lbl"&gt;Run Option:&lt;/a&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;b&gt;&lt;a href="javascript:popup('../help/help_avp_light_eu.htm#DCN_inter', '500', '300');" class="lbl"&gt;DCN Interpretation:&lt;/a&gt;&lt;/td&gt;
                          &lt;/tr&gt;
                  &lt;/table&gt;
                  &lt;/td&gt;           
                      &lt;td&gt;&lt;b&gt;&lt;a href="javascript:popup('../help/help_avp_light_eu.htm#User_name', '500', '300');" class="lbl"&gt;User Name:&lt;/a&gt;&lt;/td&gt;
                      &lt;/tr&gt;
                &lt;tr&gt;&lt;td&gt;&lt;select name='output' onchange='check_ns2(this.form)'&gt;
                 &lt;option value='Va1'&gt;Va2&lt;/option&gt;
                 &lt;option value='Va2'&gt;Va2&lt;/option&gt;
  
                       &lt;/select&gt;&amp;nbsp&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;input type='text' name='build' size=6&gt; (YYYYWW)&lt;/td&gt;
              &lt;td&gt;&lt;input type='text' id="time1" name='username' size=12&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
              &lt;td  colspan="2" class="buttonRow"&gt; 
                &lt;input TYPE="HIDDEN" name="com_site" value="comvmf"&gt;
                &lt;input TYPE="SUBMIT" name="Execute" VALUE="Submit" class="btn"&gt;&amp;nbsp;
                &lt;input TYPE="RESET" VALUE="Reset" class="btn"&gt;&amp;nbsp;                  
              &lt;/td&gt;
                &lt;/tr&gt;
              &lt;/table&gt;
            &lt;/form&gt;
  </code></pre>
  
  <p>This is my code:</p>
  
  <pre><code>public static string HttpPostWithCookie(string uri, string parameters, CookieContainer cookieContainer, out string result)
          {
              result = "ok";
              // parameters: name1=value1&amp;name2=value2          
              HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(uri);
              webRequest.CookieContainer = cookieContainer;
              webRequest.Credentials = CredentialCache.DefaultCredentials;
              webRequest.ContentType = "application/x-www-form-urlencoded";
              webRequest.Method = "POST";
              byte[] bytes = Encoding.ASCII.GetBytes(parameters);
              System.IO.Stream os = null;
              try
              { // send the Post
                  webRequest.ContentLength = bytes.Length;   //Count bytes to send
                  os = webRequest.GetRequestStream();
                  os.Write(bytes, 0, bytes.Length);         //Send it
              }
              catch (WebException ex)
              {
                  result = "HttpPost: Request error" + ex.Message;
              }
              finally
              {
                  if (os != null)
                  {
                      os.Close();
                  }
              }
  
              try
              { // get the response
                  WebResponse webResponse = webRequest.GetResponse();
                  if (webResponse == null)
                  {
                      result = "Empty response";
                      return null;
                  }
                  System.IO.StreamReader sr = new System.IO.StreamReader(webResponse.GetResponseStream());
                  return sr.ReadToEnd().Trim();
              }
              catch (WebException ex)
              {
                  result = "HttpPost: Response error" + ex.Message;
              }
              return null;
          } // end HttpPost
  </code></pre>
  
  <p>Unfortunately i can't post the data. Is there any other method to post the data to the webpage "frog_simple.php"?.All i was recieving a webresponse saying ">>ERROR. No data Submitted".</p>