0

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";
     $port = 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">
1
  • You should be able to set the form action on your php page to the asp site, if the asp site is expecting a normal form post. Are you getting an error, what is not working quite right? Maybe aspx has something that only allows the form to come from the same domain, I have not done anything with asp.net. Commented Sep 23, 2011 at 22:34

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I have an almost similar question still open but this time I am trying to make the HTML Form post to a PHP file in httpdocs (ASP.NET CORE WEB SERVER): If you manage to find time I would appreciate your assistance. I have not yet found a solution. Here is the link to the question: stackoverflow.com/questions/66402019/… Appreciated.
0

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")

2 Comments

The page just doesn't load. It's like the ASP.NET site isn't even getting the request.
Request.Form["somefieldname"], you mean.
0

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.

4 Comments

So I didn't write the PHP, don't know much about it. Doing a get request to the page does a redirect (as programmed) due to no form collection being posted. PHP above.
When you post, what are the contents of $response?
The asp.net page never gets the request for some reason.
Try changing the form action from /leads.aspx to a fully qualified domain name like www.example.com/leads.aspx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.