<p>I am doing an e-commerce solution in ASP.NET which uses <a href="https://www.paypal.com/IntegrationCenter/ic_standard_home.html" rel="noreferrer">PayPal's Website Payments Standard</a> service. Together with that I use a service they offer (<a href="https://www.paypal.com/IntegrationCenter/ic_pdt.html" rel="noreferrer">Payment Data Transfer</a>) that sends you back order information after a user has completed a payment. The final thing I need to do is to parse the POST request from them and persist the info in it. The HTTP request's content is in this form :</p>

<blockquote>
  <p>SUCCESS<br>
  first_name=Jane+Doe<br>
  last_name=Smith<br>
  payment_status=Completed<br>
  payer_email=janedoesmith%40hotmail.com<br>
  payment_gross=3.99<br>
  mc_currency=USD<br>
  custom=For+the+purchase+of+the+rare+book+Green+Eggs+%26+Ham</p>
</blockquote>

<p>Basically I want to parse this information and do something meaningful, like send it through e-mail or save it in DB. My question is what is the right approach to do parsing raw HTTP data in ASP.NET, not how the parsing itself is done.</p>

[{'answer_id': 20256, 'author': 'Greg Hurlman', 'author_id': 35, 'author_profile': 'https://Stackoverflow.com/users/35', 'pm_score': 0, 'selected': False, 'text': '<p>If I\'m reading your question right, I think you\'re looking for the <a href="http://msdn.microsoft.com/en-us/library/system.web.httprequest.inputstream.aspx" rel="nofollow noreferrer" title="MSDN">InputStream property</a> on the Request object.  Keep in mind that this is a firehose stream, so you can\'t reset it.</p>\n'}, {'answer_id': 20264, 'author': 'samjudson', 'author_id': 1908, 'author_profile': 'https://Stackoverflow.com/users/1908', 'pm_score': 1, 'selected': False, 'text': "<p>Well if the incoming data is in a standard form encoded POST format, then using the Request.Form array will give you all the data in a nice to handle manner.</p>\n\n<p>If not then I can't see any way other than using Request.InputStream.</p>\n"}, {'answer_id': 20274, 'author': 'Markus Olsson', 'author_id': 2114, 'author_profile': 'https://Stackoverflow.com/users/2114', 'pm_score': 5, 'selected': True, 'text': '<p>Something like this placed in your onload event.</p>\n\n<pre><code>if (Request.RequestType == "POST")\n{\n    using (StreamReader sr = new StreamReader(Request.InputStream))\n    {\n        if (sr.ReadLine() == "SUCCESS")\n        {\n            /* Do your parsing here */\n        }\n    }\n}\n</code></pre>\n\n<p>Mind you that they might want some special sort of response to (ie; not your full webpage), so you might do something like this after you\'re done parsing.</p>\n\n<pre><code>Response.Clear();\nResponse.ContentType = "text/plain";\nResponse.Write("Thanks!");\nResponse.End();\n</code></pre>\n\n<p>Update: this should be done in a Generic Handler (.ashx) file in order to avoid a great deal of overhead from the page model. Check out <a href="http://www.aspcode.net/Creating-an-ASHX-handler-in-ASPNET.aspx" rel="noreferrer">this article</a> for more information about .ashx files</p>\n'}, {'answer_id': 20613, 'author': 'Mark Brackett', 'author_id': 2199, 'author_profile': 'https://Stackoverflow.com/users/2199', 'pm_score': 2, 'selected': False, 'text': '<p>Use an <a href="http://msdn.microsoft.com/en-us/library/system.web.ihttphandler.aspx" rel="nofollow noreferrer">IHttpHandler</a> and avoid the Page model overhead (which you don\'t need), but use Request.Form to get the values so you don\'t have to parse name value pairs yourself. Just pretend you\'re in PHP or Classic ASP (or ASP.NET MVC, for that matter). ;)</p>\n'}, {'answer_id': 21968, 'author': 'Anders Eurenius', 'author_id': 1421, 'author_profile': 'https://Stackoverflow.com/users/1421', 'pm_score': 2, 'selected': False, 'text': "<h2>I'd strongly recommend saving each request to some file.</h2>\n\n<p>This way, you can always go back to the actual contents of it later. You can thank me later, when you find that hostile-endian, koi-8 encoded, [...], whatever it was that stumped your parser...</p>\n"}]
['https://Stackoverflow.com/questions/20245', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1801/']