Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The button HTML from the PayPal site is embedded in a form tag. You can only have one form on an ASP.NET page and ASP.NET provides its own. If you have a master page, then the form tag is in there and it is applied to every page in the site when they are merged with the master at runtime.</p> <p>I found an <a href="http://jerschneid.blogspot.com/2007/03/hide-form-tag-but-leave-content.html" rel="nofollow">elegant solution</a> on Jeremy Schneider's blog that consists of a custom HtmlForm class that can have the form tag rendering toggled on and off. The class is called GhostForm and has a property, RenderFormTag. When RenderFormTag is set to false, it doesn't render the opening or closing tags, but does render all of the contents. Reference the custom GhostForm class and in the code-behind of the form on which you are placing the button, place the following in the Page_Load to disable the master page form tag:</p> <p>Usage:</p> <pre><code>public partial class Products : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { GhostForm mainForm = new GhostForm(); mainForm.RenderFormTag = false; ..... } // Send your data to PayPal :-) ..... } </code></pre> <p><strong>IMPORTANT:</strong> make sure you are signed into the sandbox BEFORE sending this request.</p> <p><strong>UPDATE:</strong> Check out these instructional videos: <a href="http://www.asp.net/mvc/videos/mvc-1/aspnet-mvc-storefront/aspnet-mvc-storefront-part-1-architectural-discussion-and-overview" rel="nofollow">http://www.asp.net/mvc/videos/mvc-1/aspnet-mvc-storefront/aspnet-mvc-storefront-part-1-architectural-discussion-and-overview</a></p> <p>Like you, I used the IPN code from John Mendez. Here's where I send and receive from PayPal:</p> <pre><code>string strSandbox = "https://www.sandbox.paypal.com/cgi-bin/webscr"; HttpWebRequest req = (HttpWebRequest)WebRequest.Create(strLive); //Set values for the request back to PayPal req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; byte[] param = Request.BinaryRead(HttpContext.Current.Request.ContentLength); string strRequest = Encoding.ASCII.GetString(param); strRequest += "&amp;cmd=_notify-validate"; req.ContentLength = strRequest.Length; //Send the request to PayPal StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII); streamOut.Write(strRequest); streamOut.Close(); // Get the response from PayPal StreamReader streamIn = new StreamReader(req.GetResponse().GetResponseStream()); string strResponse = streamIn.ReadToEnd(); streamIn.Close(); </code></pre> <p>Hopefully this helps. 500 errors could be anything...</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload