Sending array by POST request

j0sur

New member
Joined
Jun 22, 2012
Messages
3
Programming Experience
3-5
I have an form like:
HTML:
<form action="script.php" method="post" name="post">
<input name="form[value1]" type="text" size="45"><br />
<input name="form[value2]" type="text" size="45"><br />
<textarea name="form[value3]"></textarea><br />
<textarea name="form[value4]"></textarea><br />
<textarea name="form[value5]"></textarea><br />
<input type="submit" name="ok" value="Отправить">
</form>
And I need to make an request to this script. So I have this code:
VB.NET:
Private Function POSTreq(ByVal url As String, ByVal params As List(Of String)) As String
        Dim reqPOST As System.Net.WebRequest = System.Net.WebRequest.Create(url)
        reqPOST.Method = "POST"
        reqPOST.Timeout = 120000
        reqPOST.ContentType = "application/x-www-form-urlencoded"
        Dim sentData As Byte() = System.Text.Encoding.GetEncoding(1251).GetBytes(System.Web.HttpUtility.UrlEncode(String.Join("&", params.ToArray), System.Text.Encoding.GetEncoding(1251)))
        reqPOST.ContentLength = sentData.Length
        Dim sendStream As System.IO.Stream = reqPOST.GetRequestStream()
        sendStream.Write(sentData, 0, sentData.Length)
        sendStream.Close()
        Dim res As System.Net.WebResponse = reqPOST.GetResponse
        Return (New IO.StreamReader(res.GetResponseStream, System.Text.Encoding.GetEncoding(1251))).ReadToEnd
    End Function
In the params i put list of "form[value1]=value" , etc.
But my script returns an error(no one of field is set), but there are no errors in script, it works fine in brawser. What can I do to make this code working? Sanx a lot.
 
Back
Top