ASP.NET POST function in C# code
<p>I have some html POSTing code that I'm trying to emulate in an C# event.</p>

<pre><code>&lt;FORM method=post name=agree action=http://1.1.1.1/agree.cgi&gt;
&lt;INPUT value=Agree type=hidden name=hdnAgree&gt;&amp;nbsp;
&lt;INPUT value=Agree type=submit name=agree&gt;
&lt;/FORM&gt;
</code></pre>

<p>I heard you can also use the UploadString
The code below is not working</p>

<pre><code>WebRequest webRequest = WebRequest.Create("http://1.1.1.1/agree.cgi");
webRequest.Method = "POST";
webRequest.ContentType = "application/x-www-form-urlencoded";
string parameters = "name=agree";
byte[] bytes = Encoding.UTF8.GetBytes(parameters);
webRequest.ContentLength = bytes.Length;
Stream dataStream = webRequest.GetRequestStream();
dataStream.Write(bytes, 0, bytes.Length);
dataStream.Close();
</code></pre>
