【发布时间】:2011-09-23 13:07:10
【问题描述】:
我正在编写一个小型 API,需要检查请求中的重复键。有人可以推荐检查重复键的最佳方法。我知道我可以在 key.Value 中检查字符串中的逗号,但是我遇到了另一个问题,即不允许在 API 请求中使用逗号。
//Does not compile- just for illustration
private void convertQueryStringToDictionary(HttpContext context)
{
queryDict = new Dictionary<string, string>();
foreach (string key in context.Request.QueryString.Keys)
{
if (key.Count() > 0) //Error here- How do I check for multiple values?
{
context.Response.Write(string.Format("Uh-oh"));
}
queryDict.Add(key, context.Request.QueryString[key]);
}
}
【问题讨论】:
标签: c# query-string