8

Is there any way to get all the POST data sent to a .NET webpage?

Basically I am looking for the equivalent of the PHP $_POST array

The purpose being that I am receiving requests from a client that I have no control over and need to get all the data without knowing they keys.

therealsix
  • 656
  • 2
  • 7
  • 16

4 Answers4

18
foreach(string name in Request.Form)
{
    Response.Write(Request.Form[name]);
}
Rubens Farias
  • 57,174
  • 8
  • 131
  • 162
  • is there a way to get it when there is no form ? – Omu May 11 '12 at 16:47
  • @ChuckNorris, you're probably talking about query string arguments; try replace `Request.Form` with `Request.QueryString` – Rubens Farias May 11 '12 at 17:39
  • no, it's also empty, I'm posting from flash using NetConnection, here's the question http://stackoverflow.com/q/10519617/112100 – Omu May 11 '12 at 18:18
4

You want Request.Form There's a keys collection in there you can iterate through.

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
0
 HttpContext.Current.Request.Params.ToString()
  • Your answer could be improved by adding more information on what the code does and how it helps the OP. – Tyler2P Dec 19 '22 at 17:02
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/33447748) – DSDmark Dec 22 '22 at 11:57
-3

You can use return Request.Form.ToString(); to get raw POST data.

Philip Pittle
  • 11,821
  • 8
  • 59
  • 123