HttpWebRequest problem: Please help

  • Thread starter Thread starter Sojwal
  • Start date Start date
S

Sojwal

We are working on a asp.net application in which we need to send some
data to a PHP application on another server. We are using
HttpWebRequest object to 'POST' the data to a PHP page as key-value
pairs, which will be accessed by the PHP script as posted variables.
The requirement is to name all keys in the posted data as the same
name, which ideally should result in getting an array of the data on
the PHP side. For example, if data is sent as
"key=abc&key=def&key=123" then the PHP page should get an array
containing members "abc", "def" & "123". This is not happening..what
we get on PHP side is a single comma separated string
like "abc,def,123". The code for posting form data using
HttpWebRequest is standard as shown on many sites. What are we doing
wrong here?
Thanks in advance.
 
Sojwal said:
We are working on a asp.net application in which we need to send some
data to a PHP application on another server. We are using
HttpWebRequest object to 'POST' the data to a PHP page as key-value
pairs, which will be accessed by the PHP script as posted variables.
The requirement is to name all keys in the posted data as the same
name, which ideally should result in getting an array of the data on
the PHP side. For example, if data is sent as
"key=abc&key=def&key=123" then the PHP page should get an array
containing members "abc", "def" & "123". This is not happening..what
we get on PHP side is a single comma separated string
like "abc,def,123". The code for posting form data using
HttpWebRequest is standard as shown on many sites. What are we doing
wrong here?

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
 
Jon Skeet said:
Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

The problem was solved by posting the data as
"key[]=abc&key[]=def&key[]=123" as required by PHP. But thanks for
replying to my post. I did read your helpful article on 'short but
complete program' & will keep this in mind when posting to newsgroups.
Thanks for the tips. :-)
 
Back
Top