[英]NameValueCollection from Form.Post show FIELDS and VALUES
I need to grab all the FIELD and VALUES from a POST.我需要从 POST 中获取所有 FIELD 和 VALUES。
I have the follow which only return the FIELDs but no Values.我有以下内容,它只返回字段但不返回值。
NameValueCollection authForm = Request.Form;
String[] a = authForm.AllKeys;
for (i = 0; i < a.Length; i++)
{
frm += ("Form: " + a[i] + " : " + "<br>");
}
Response.Write(frm);
What can I add this the frm string to show the VALUES?我可以添加什么 frm 字符串来显示值?
UPDATE:更新:
I used the initial code of我使用了初始代码
NameValueCollection authForm = Request.Form;
foreach (string key in authForm.AllKeys)
{
frm += ("Key: " + key + ", Value: " + authForm[key] + "<br/>");
}
which worked great.效果很好。 I will try the new variation below.
我将尝试下面的新变体。
NameValueCollection authForm = Request.Form;
StringBuilder sb = new StringBuilder();
foreach (string key in authForm.AllKeys)
{
sb.AppendFormat(
"Key: {0}, Value: {1}<br/>",
HttpUtility.HtmlEncode(key),
HttpUtility.HtmlEncode(authForm[key])
);
}
Response.Write(sb.ToString());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.