C# 表单中的NameValueCollection.Post显示字段和值

C# 表单中的NameValueCollection.Post显示字段和值,c#,asp.net,collections,C#,Asp.net,Collections,我需要从帖子中获取所有字段和值 我有一个follow,它只返回字段,不返回值 NameValueCollection authForm = Request.Form; String[] a = authForm.AllKeys; for (i = 0; i < a.Length; i++) { frm += ("Form: " + a[i] + " : " + "<br>"); } Response.Write(frm); NameValueCollection

我需要从帖子中获取所有字段和值

我有一个follow,它只返回字段,不返回值

NameValueCollection authForm = Request.Form;
String[] a = authForm.AllKeys;

for (i = 0; i < a.Length; i++)
{
    frm += ("Form: " + a[i] + " : " + "<br>");
}

Response.Write(frm);
NameValueCollection authForm=Request.Form;
字符串[]a=authForm.AllKeys;
对于(i=0;i”);
}
响应写入(frm);
我可以在frm字符串中添加什么来显示值

更新:

我使用了

    NameValueCollection authForm = Request.Form;
    foreach (string key in authForm.AllKeys)
    {
        frm += ("Key: " + key + ", Value: " + authForm[key] + "<br/>");
    }
NameValueCollection authForm=Request.Form;
foreach(authForm.AllKeys中的字符串键)
{
frm+=(“键:“+Key+”,值:“+authForm[Key]+”
); }
这很有效。我将尝试下面的新变体。

NameValueCollection authForm=Request.Form;
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());
StringBuilder sb=新的StringBuilder(); foreach(authForm.AllKeys中的字符串键) { 附文格式( 键:{0},值:{1}
, HttpUtility.HtmlEncode(键), HttpUtility.HtmlEncode(authForm[key]) ); } 写(某人写的东西);
+1,但如果您使用
string.Format
StringBuilder.AppendFormat
:-)则会更漂亮