tags:

views:

97

answers:

2

I have a 3rd party submitting data via form post. I want to capture the contents of the post without actually doing

Request[FormElementName"].ToString()

for every element that i am expecting

Is there some method/property in the Request object which would allow me to capture the entire form post? Something similar to

Request.RawUrl.ToString()
A: 

You can get all posted elements by Page.Request.Form collection.

Canavar
+3  A: 

The Request.Form property returns a NameValueCollection containing all the posted parameters.

You could do something as simple as :

NameValueCollection nvc = Request.Form;
foreach (string key in nvc.AllKeys)
{
  Debug.WriteLine("Key - " + key);
  Debug.WriteLine("Value - " + nvc[key]);
  Debug.WriteLine("---");
}

Edit: If you need to query QueryString values as well, use the Request.Params property in the same manner.

Cerebrus