.net后台得到Request.QueryString所有参数的键值

代码

string str = "";
                int num = 0;
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                num = Request.QueryString.Count;
                sb.AppendLine("共有" + num.ToString() + "个参数<br/>");
                foreach (string key in Request.QueryString.AllKeys)
                {
                    sb.AppendLine(string.Format("Key={0}&nbsp;&nbsp;&nbsp;Value={1}<br/>", key, Request.QueryString[key]));
                }

结果

共有2个参数<br/>
Key=toUserid&nbsp;&nbsp;&nbsp;Value=138<br/>
Key=comeUserid&nbsp;&nbsp;&nbsp;Value=659<br/>
 

 

posted @ 2020-06-18 09:44  离。  阅读(49)  评论(0编辑  收藏