How do you get all the post request variables in C#?

Gre*_*zer 5 c# asp.net

I am getting a post from an external vendor. I am not exactly sure what variables they are sending. How do I print out all the Request variables that they are sending in the post? there is no Request.Count or Request.Length so that I could loop and find everything.

Thanks in advance for your help.

And*_*bel 16

该Request.Form属性包含一个包含所有表单域的集合.它是一个NameValueCollection实现的,ICollection所以你应该能够循环它foreach.Request.Form.Keys将为您提供所有表单字段名称,然后您可以使用该名称来查找该值.

foreach(string key in Request.Form.Keys)
{
  Response.Write(key + ": " + Request.Form[key] + "<br/>");
}
Run Code Online (Sandbox Code Playgroud)


Waq*_*jua 9

你可以从Request.Forms获得它

foreach(string key in Request.Form.Keys ) 
{
  Response.Write ( key );
}
Run Code Online (Sandbox Code Playgroud)