I have three PHP web sites that collect a small amount of form data. I want to set the action of these PHP pages to post to the ASP.NET (another instance) web site.
On the ASPX side, on page load, I'm looking for the form collection, and doing some stuff in SQL with it.
I thought that an ASPX page could just receive a form post from another web site? Am I way off base? Ideas?
The snippet of PHP code that does the post (I think)
$host = "www.myaspnetwebsite.com";
$po开发者_Go百科rt = 80;
$path = "/leads.aspx";
//send the server request
fputs($fp, "POST $path HTTP/1.1\r\n");
fputs($fp, "Host: $host\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: ".strlen($poststring)."\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $poststring . "\r\n\r\n");
//loop through the response from the server
while(!feof($fp)) {
$response .= fgets($fp, 4096);
}
//close fp - we are done with it
fclose($fp);
The form is on an HTML page with action of the PHP (snip) above. There's more in the file, but that looks like what's doing the post.
<form action="process-final.php" method="post" id="in-quote-form">
I'm doing something along these lines ATM. I'm testing my code with a HTML file containing a simple <form method="post" action="targetpage.aspx">
, at first it didn't work because I was using the id attribute because I thought the name attribute was deprecated. It turns out though that it only works with Request.Form("X")
where <input type="text" name="X" />
. Hope this helps.
Have you tried this and you are having a problem? Or just asking if it's possible?
In the Page_Load
event you can use Request.Form("somefieldname")
I've written asp.net applications that receive POST data from my customer's applications, so I can assure you that what you are trying to do is possible.
Are you sure the asp.net application is working correctly? What happens if you attempt a GET request to the resource you are trying to POST to?
Can you post the opening form tag of your php application? Is the action a fully qualified domain name (i.e. http://www.example.com/customers)? I don't believe a relative url will work unless the applications share a directory structure.
We need a bit more information to really help you nail this down.
精彩评论