With this simple ASP code, we can see how checkboxes values are sent through a POST request:
tst.asp
<%
Dim chks
chks = Request.Form("chks")
%>
<html>
<head>
<title>Test page</title>
</head>
<body>
<form name="someForm" action="" method="POST">
<input type="checkbox" id="chk01" name="chks" value="v1" />
<input type="checkbox" id="chk02" name="chks" value="v2" />
<input type="checkbox" id="chk03" name="chks" value="v3" />
<input type="submit" value="Submit!" />
</form>
<h3>Last "chks" = <%= chks %></h3>
</body>
</html>
The H3 line show us this, if we check all the checkboxes:
Last "chks" = v1, v2, v3
Now we know how the data should be posted. With the sample code below, you should be able to do it.
C# method sample
using System.Text;
using System.Net;
using System.IO;
using System;
...
void DoIt()
{
String querystring = "chks=v1, v2, v3";
byte[] buffer = Encoding.UTF8.GetBytes(querystring);
WebRequest webrequest = HttpWebRequest.Create("http://someUrl/tst.asp");
webrequest.ContentType = "application/x-www-form-urlencoded";
webrequest.Method = "POST";
webrequest.ContentLength = buffer.Length;
using (Stream data = webrequest.GetRequestStream())
{
data.Write(buffer, 0, buffer.Length);
}
using (HttpWebResponse webresponse = (HttpWebResponse)webrequest.GetResponse())
{
if (webresponse.StatusCode == HttpStatusCode.OK)
{
/* post ok */
}
}
}
Hope I've helped.
Useful links: