C# WebApi将查询字符串RequestUri.Query解析转换为Hashtable
C# WebApi将查询字符串RequestUri.Query解析转换为Hashtable
//判断参数
if (String.IsNullOrEmpty(query) || query.Length < 10)
return new ModelResponse { Code = -1, Message = "notify_url参数错误!" };
//去掉问号?,第1个字符
query = query.Replace("?", "");
string[] items = query.Split(new char[] { '&' }, StringSplitOptions.RemoveEmptyEntries);
string[] values;
Hashtable ht = new Hashtable();
foreach (string item in items)
{
values = item.Split('=');
ht.Add(values[0], values[1]);
string query = this.Request.RequestUri.Query;
if (String.IsNullOrEmpty(query) || query.Length < 10)
return new ModelResponse { Code = -1, Message = "notify_url参数错误!" };
//去掉问号?,第1个字符
query = query.Replace("?", "");
string[] items = query.Split(new char[] { '&' }, StringSplitOptions.RemoveEmptyEntries);
string[] values;
Hashtable ht = new Hashtable();
foreach (string item in items)
{
values = item.Split('=');
ht.Add(values[0], values[1]);
}
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网