Exemple #1
0
        /// <summary>
        /// 获取参数,并以“参数名=参数值”的形式组成数组
        /// </summary>
        /// <param name="method">GET/POST</param>
        /// <returns></returns>
        public static SortedDictionary <string, string> GetRequest(string method = "GET")
        {
            SortedDictionary <string, string> sArray = new SortedDictionary <string, string>();

            NameValueCollection coll = null;

            if (string.Compare(method, "POST", true) == 0)
            {
                coll = HttpContext.Current.Request.Form;
            }
            else
            {
                coll = HttpContext.Current.Request.QueryString;
            }

            if (coll != null)
            {
                string[] keys = coll.AllKeys;
                if (keys != null && keys.Length > 0)
                {
                    for (int i = 0; i < keys.Length; i++)
                    {
                        sArray.Add(keys[i], UrlParameterHelper.GetForm(keys[i]));
                    }
                }
            }

            return(sArray);
        }