Gets the collection of QueryString variables.
[Visual Basic] Public ReadOnly Property QueryString As NameValueCollection [C#] public NameValueCollection QueryString {get;} [C++] public: __property NameValueCollection* get_QueryString(); [JScript] public function get QueryString() : NameValueCollection;
A managed reference to an HttpValueCollection object containing the collection of QueryString variables sent by client.
This example accepts the query string from a Form (with Method attribute = Get) and writes out the names and values of each named Input element on the form. This code would be placed on the aspx page referenced by the form's "Action =" attribute.
[Visual Basic]
<% Dim iLoop1 As Integer Dim iLoop2 as Integer Dim iCount as integer Dim oQs as NameValueCollection Dim sArr1(10) As String ' Make sure arrays are larger than required. Dim sArr2(10) As String oQs=Request.QueryString ' Load query string into variable. iCount =(oQs.Count) ' Find number of input fields. response.write("Number of inputs is " & CStr(iCount) & "<br>") sArr1 = oQs.Allkeys ' Get names of input elements into array. ' Loop through NameValueCollection, print input element names and values under each. for iLoop1 = 0 to Ubound(sArr1) sArr2 = oQs.GetValues(sArr1(iLoop1)) ' Get values stored under key. response.write("Values of " & sArr1(iLoop1) & ":<br>") ' Key name. for iLoop2 = 0 to ubound(sArr2) if sArr2(iLoop2) <> "" then response.write(sArr2(iLoop2) & "<br>") ' Value under key. end if next iLoop2 Next iLoop1 %>
HttpRequest Class | HttpRequest Members | System.Web Namespace