{"id":90,"date":"2006-10-09T08:36:57","date_gmt":"2006-10-09T13:36:57","guid":{"rendered":"\/cgi\/wp\/?p=90"},"modified":"2006-10-09T08:46:04","modified_gmt":"2006-10-09T13:46:04","slug":"aspnet-enumerate-query-string-values","status":"publish","type":"post","link":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/?p=90","title":{"rendered":"ASP.NET Enumerate Query String Values"},"content":{"rendered":"<p>Although it is fairly easily to get a single query string value, I recently found it was very difficult to get the entire querystring which I wanted to include in an error report. In order to store the querystring in a variable you need to create a NameValueCollection from the System.Collections.Specialized namespace:<\/p>\n<p><code><br \/>\n&lt;%@ Import Namespace=&quot;System.Collections.Specialized&quot;%&gt;<br \/>\n&lt;script language=&quot;vb&quot; runat=&quot;server&quot;&gt;<br \/>\nDim param As NameValueCollection<br \/>\nparam = Request.QueryString<br \/>\n<\/code><\/p>\n<p>Then you will need two For  loops (i.e. nested loops) to get the collection&#8217;s keys and values:<\/p>\n<p><code><br \/>\nDim i, j As Integer<br \/>\nDim arr1() As String = param.AllKeys<br \/>\nFor i = 0 To  arr1.Length - 1<br \/>\n&nbsp; &nbsp; Dim arr2() As String = param.GetValues(arr1(i))<br \/>\n &nbsp; &nbsp; For j = 0 To  arr2.Length - 1<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; strQueryStringValue = strQueryStringValue & arr1(i) & \"=\" & arr2(j) & \"&\"<br \/>\n &nbsp; &nbsp; Next<br \/>\nNext<\/code><\/p>\n<p>This problem came up because I was trying to troubleshoot some code which I did not write. The previous developer gave a form the GET method and was passing a memo field in the querystring. This is bad programming because the querystring is not meant for lengthy amounts of text. There is a limit to the allowable length of a querystring. Many firewalls will truncate a querystring because lengthy querystrings are used to cause buffer overflows in web servers and browsers. Therefore I wanted to get the length of the entire querystring for my error report.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Although it is fairly easily to get a single query string value, I recently found it was very difficult to get the entire querystring which I wanted to include in an error report. In order to store the querystring in &hellip; <a href=\"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/?p=90\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=\/wp\/v2\/posts\/90"}],"collection":[{"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=90"}],"version-history":[{"count":0,"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=\/wp\/v2\/posts\/90\/revisions"}],"wp:attachment":[{"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=90"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=90"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=90"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}