コード例 #1
0
        /// <summary>
        /// Returns a hashtable of the query parameters parsed from a URL
        /// </summary>
        /// <param name="url">The url from which to get the query parameters (Note: This will be fooled
        /// by html escaped strings such as &amp; in the url)</param>
        /// <returns>A hashtable of the parameters</returns>
        public static Hashtable GetQueryParams(string url)
        {
            Hashtable queryParams = new DefaultHashtable(new DefaultHashtable.DefaultValuePump(DefaultHashtable.ArrayListDefault));

            Uri uri = new Uri(url);

            string trimmedUrl = uri.Query.TrimStart('?');

            string[] pairs = trimmedUrl.Split('&');
            foreach (string pair in pairs)
            {
                string[] splitPairs = pair.Split('=');
                if (splitPairs.Length == 2)
                {
                    ((ArrayList)queryParams[splitPairs[0]]).Add(splitPairs[1]);
                }
            }

            return(queryParams);
        }
コード例 #2
0
        /// <summary>
        /// Returns a hashtable of the query parameters parsed from a URL
        /// </summary>
        /// <param name="url">The url from which to get the query parameters (Note: This will be fooled
        /// by html escaped strings such as &amp; in the url)</param>
        /// <returns>A hashtable of the parameters</returns>
        public static Hashtable GetQueryParams(string url)
        {
            Hashtable queryParams = new DefaultHashtable(new DefaultHashtable.DefaultValuePump(DefaultHashtable.ArrayListDefault));

            Uri uri = new Uri(url);

            string trimmedUrl = uri.Query.TrimStart('?');
            string[] pairs = trimmedUrl.Split('&');
            foreach (string pair in pairs)
            {
                string[] splitPairs = pair.Split('=');
                if (splitPairs.Length == 2)
                    ((ArrayList)queryParams[splitPairs[0]]).Add(splitPairs[1]);
            }

            return queryParams;
        }