通过POST解析 [英] Parse through POST
本文介绍了通过POST解析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用流阅读器来阅读 context.Request.InputStream
来的结束,以及一个字符串看起来像
I use Stream reader to read context.Request.InputStream
to the end and end up with a string looking like
"Gamestart=true&GamePlayer=8&CurrentDay=Monday&..."
什么是最efficent /干净的方式来分析,在C#控制台?
What would be the most efficent/"clean" way to parse that in a C# console?
推荐答案
您可以使用 HttpUtility.ParseQueryString
You can use HttpUtility.ParseQueryString
小样本:
string queryString = "Gamestart=true&GamePlayer=8&CurrentDay=Monday"; //Hardcoded just for example
NameValueCollection qscoll = HttpUtility.ParseQueryString(querystring);
foreach (String k in qscoll.AllKeys)
{
//Prints result in output window.
System.Diagnostics.Debug.WriteLine(k + " = " + qscoll[k]);
}
这篇关于通过POST解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文