.net接收post請求並把資料轉為字典格式

網咖看壓力大發表於2018-11-21

public SortedDictionary<string, string> GetRequestPost()
{
int i = 0;
SortedDictionary<string, string> sArray = new SortedDictionary<string, string>();
NameValueCollection coll = Request.Form;

String[] requestItem = coll.AllKeys;

for (i = 0; i < requestItem.Length; i++)
{
sArray.Add(requestItem[i], Request.Form[requestItem[i]]);
}

coll.Clear();

return sArray;
}

呼叫:

SortedDictionary<string, string> sPara = GetRequestPost();

相關文章