trying to submit an httpwebrequest with hidden field and submit button data
-
Hi - I'm implementing PayPal PDT (Payment Data Transfer) for payment confirmations in ASP.NET. I'm going to receive a url post from PayPal with query string parameters. Then I need to send back the form at the bottom of the page. I'd like to implement the form at the bottom as a non-visual HttpWebRequest. So far I have this code: string urlPayPalEnvironment = "https://www.paypal.com/cgi-bin/webscr"; // Prepare web request. HttpWebRequest request = WebRequest.Create(urlPayPalEnvironment) as HttpWebRequest; request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; Can you help me extend this code to include the required hidden fields? I've seen code on the web that builds a data string like this: string postData = "cmd=_notify-synch" + "&tx=" + txId + "&at=" + merchantIdentityToken; Is this how HttpWebRequest works internally - hidden fields are simply converted into name-value pairs in a querystring? Also - I'm not sure how the submit input would be added to this. It just has a value of "PDT" in the required form format below with no name. Any ideas on how to handle this? Also - I've seen some examples where the HttpWebRequest just gets streamed out but I'd like an OO approach using the HttpWebResponse to get a handle to the response. Thanks for your help! <form method=post action="https://www.paypal.com/cgi-bin/webscr"> <input type="hidden" name="cmd" value="_notify-synch"> <input type="hidden" name="tx" value="TransactionID"> <input type="hidden" name="at" value="YourIdentityToken"> <input type="submit" value="PDT"> </form>