0

I'm trying to POST data to an PHP page using c#.

I tried the MSDN example (I changed the postData to "xml=test") and I tried the example of this post.

The PHP page is very simple. It currently contains:

<?php echo "PostData<br>"; echo "<pre>"; print_r($_POST); echo "</pre>"; ?>

I wrote a simple HTML file for testing. It only contained a form to post data.

<html>
<body>
<form action = "https://myurl/upload/uploadTest.php" method = "post">
<input name = "xml" value="test"><p>
<input type = "submit" value="absenden">
</form>
</body>
</html>

The response of the HTML site is:

PostData
Array
(
    [xml] => test
)

This means to me that the connection and the PHP file is ok.

But the response of my c# code is:

OK

PostData<pre>Array
(
)
</pre>

The "OK" comes from "(((HttpWebResponse)response).StatusDescription)" and the rest is "reader.ReadToEnd()".

Can someone tell me why the html file works and the c# not?
And how can I get the c# upload working?

Community
  • 1
  • 1
  • the
     tags are just not visible when you view the HTML site. Do you get the [xml] => test on the C# code?
    – Shai Aharoni Mar 06 '14 at 08:43
  • Is it possible to get your C# application to use a web debugging proxy like Charles? This would allow you to view the request headers being generated by the C# application and debug the issue – PiX06 Mar 06 '14 at 08:48
  • Can you share the c# code as well? looks like you are not passing any POST variables from C# – SajithNair Mar 06 '14 at 08:56

0 Answers0