示例#1
0
        protected virtual void initHttpParams()
        {
            Dictionary <string, object> requestParams = Tool.ParseQueryString(this.Query);

            if (this.Method == Request.METHOD_POST)
            {
                string       contentType = this.contextRequest.ContentType.ToLower();
                StreamReader reader      = new StreamReader(this.contextRequest.InputStream);
                Dictionary <string, object> postParams = new Dictionary <string, object>();
                if (contentType.IndexOf("application/x-www-form-urlencoded") > -1)
                {
                    try {
                        postParams = Tool.ParseQueryString(reader.ReadToEnd());
                    } catch (System.Exception e) {}
                }
                else if (contentType.IndexOf("text/plain") > -1)
                {
                    while (!reader.EndOfStream)
                    {
                        string line = reader.ReadLine();
                        Tool.ParseQueryStringItem(ref line, ref postParams);
                    }
                }
            }
            this.Params = requestParams;
        }
示例#2
0
        public static Dictionary <string, object> ParseQueryString(string queryString = "")
        {
            Dictionary <string, object> result = new Dictionary <string, object>();

            if (String.IsNullOrEmpty(queryString))
            {
                return(result);
            }
            queryString = queryString.TrimStart('?');
            string[] exploded = queryString.Split('&');
            string   item;

            for (int i = 0, l = exploded.Length; i < l; i += 1)
            {
                item = exploded[i];
                Tool.ParseQueryStringItem(ref item, ref result);
            }
            return(result);
        }