private void CreateItemsFromQuery() { queryItems.Clear(); if (base.Query.Length > 0) { string query = HttpUtility.UrlDecode(base.Query.Substring(1)); string[] items = query.Split('&'); foreach (string item in items) { if (item.Length > 0) { string[] namevalue = item.Split('='); if (namevalue.Length > 1) { queryItems.Add(namevalue[0], namevalue[1]); } else { queryItems.Add(namevalue[0], ""); } } } } }
/// <summary> /// Rebuilds the query item collection from its string representation. /// </summary> private void CreateItemsFromQuery() { _QueryItems.Clear(); if (base.Query.Length > 0) { string query = Uri.UnescapeDataString(base.Query.Substring(1)); string[] items = query.Split('&'); foreach (string item in items) { if (item.Length > 0) { string[] namevalue = item.Split('='); _QueryItems.Add(namevalue[0], namevalue.Length > 1 ? namevalue[1] : String.Empty); } } } }
/// <summary> /// Rebuilds the query item collection from its string representation. /// </summary> private void CreateItemsFromQuery() { _QueryItems.Clear(); if (base.Query.Length > 0) { // The Query component of the URI always begins with the ? separator, so get the entire string // after that, then split the string on the & separator, which is how each query item is delimited string query = base.Query.Substring(1); string[] items = query.Split('&'); foreach (string item in items) { if (item.Length > 0) { // Split the query item into a name/value pair, delimited by the first occurrence of =. Any // subsequent occurrences will be ignored despite being illegal as a non-URL encoded character string[] namevalue = item.Split(new char[] { '=' }, 2); // Add the name/value pair to the query item collection _QueryItems.Add(namevalue[0], namevalue.Length > 1 ? namevalue[1] : String.Empty); } } } }