Post an array

May 23, 2013 at 5:38 PM
I want to post an array to my page.
I am trying to use an int array for this but am unable to achieve results.

I want to post data of the following format:
<form method='post' action="http://www.myurl.com/a1.php">
            <input type=text name="search_ids[]" value="412"> 
            <input type=text name="search_ids[]" value="3245">
            <input type=text name="search_ids[]" value="520">
            <input type=text name="search_ids[]" value="612"> 
            <input type=submit>
</form>
Please Help.
May 23, 2013 at 6:19 PM
You cant use int array for that purpose.Convert it into string and then
Post.
To observe clearly ,use Fiddler 2 to see how browser posts to
It and then use that string to make your own post string.
May 24, 2013 at 6:59 PM
Edited May 24, 2013 at 7:00 PM
Thanks for your help.
I used fiddler and webclient to do the above call...
It solved my problem.

            string uri = "http://mywebsitecom/";
            try
            {
                WebClient webClient = new WebClient();
                webClient.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";

                webClient.Encoding = Encoding.UTF8;
                string postdata = "search_ids[]=412&search_ids[]=3245&search_ids[]=520&search_ids[]=612";
                webClient.Headers[HttpRequestHeader.ContentLength] = postdata.Length.ToString();
                webClient.UploadStringCompleted += new UploadStringCompletedEventHandler((sender, e) =>
                {
                    if (e.Error != null)
                    {
                        MessageBox.Show("Error");
                        return;
                    }
                    MessageBox.Show(e.Result);
                    tb1.Text = e.Result;
                });
                webClient.UploadStringAsync(new Uri(uri, UriKind.RelativeOrAbsolute), "POST", postdata);
            }
            catch(Exception er)
            {
                MessageBox.Show(er.Message);
            }