我想吐出 Request.Form 中的所有内容,这样我就可以将它作为字符串返回,看看我在处理什么。我尝试设置一个 for 循环...
// Order/Process
// this action is the submit POST from the pricing options selection page
// it consumes the pricing options, creates a new order in the database,
// and passes the user off to the Edit view for payment information collection
[AcceptVerbs(HttpVerbs.Post)]
public string Process()
{
string posted = "";
for(int n = 0;n < Request.Form.Count;n++)
posted += Request.Form[n].ToString();
return posted;
}
但我得到的只是“12”,我知道表格上还有很多东西......
最佳答案
StringBuilder s = new StringBuilder();
foreach (string key in Request.Form.Keys)
{
s.AppendLine(key + ": " + Request.Form[key]);
}
string formData = s.ToString();
关于c# - 如何在不知道任何细节的情况下遍历Request.Form?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1493189/