Sideway
output.to from Sideway
Draft for Information Only

Content

Request Object
 Request.QueryString Collection
   Syntax:
   Parameters:
   Remarks:
   Examples:

Request Object

The main function of Request object is the retrieving of HTTP request variables from the client.

Request.QueryString Collection

Request.QueryString Collection retrieves the variable values of  query string which is sent in the HTTP request.

Syntax:

Request.QueryString(variable)[(index)|.Count]

 Or in an ASP file. Imply

<% Request.QueryString(variable)[(index)|.Count] %>

Parameters:

variable

The parameter "variable" is the name of the variable in the HTTP query string to be retrieved. The data type of "variable" is string and is enclosed by quotation marks (" ").

index

The optional parameter "index" is the number of the index of a variable with multiple values in the HTTP query string to be retrieved. The data type of "index" is an integer and the range is from 1 to  Request.QueryString(variable).Count

.Count

The parameter "Count" is the optional information of the parameter "variable" with delimeter ".". The parameter "Count" is a read-only attribute to return the total number of the available values of the parameter " variable".

Remarks:

The HTTP query string is the string following the question mark (?) in an HTTP request. For example:

http://127.0.0.1/default.asp?qrystring=qrystringtvalue

Although query string are usually generated by a response page output, query string are only strings contained in an request headers. The values of query strings can also be generated by any user. Therefore header data or user input should be encoded or be validated before using.

 The QueryString Collection is the detailed version of the Query_String variable of the ServerVariables Collection. With the Request.QueryString Collection, the value of query string can be retrieved by name.

For variable with multiple values, the value of Request.QueryString(variable) will be in form of an array of all values of the variable in the Query_String. And the number of multiple values of the variable can be obtained by  Request.QueryString(variable).Count. For single value varible,  Request.QueryString(variable).Count equal to 1. If the variable does not exist,   Request.QueryString(variable).Count equal to 0.

And therefore the multiple values of a variable can be referenced by the parameter "index",  Request.QueryString(variable)(index). and the range of the index is from 1 to  Request.QueryString(variable).Count.

However, if the index is not specified for a multiple values variable, the Request.QueryString(variable) will return all values in the form of comma-delimited string.

Besides, if there is no specified variable for the Request.QueryString(), the Request.QueryString() will return the unparsed QueryString data.

Since the multiple values of a variable is in the form of an array, the values of the variable can be retrieved using a for index loop or a for each element loop. 

Examples:

  • HTTP Request

    HTTP Request:

    http://127.0.0.1/default.asp?A=9&B=1&B=2

  • With no variable specified in Request.QueryString

    ASP script command:

    <%= Request.QueryString %>

    HTTP response output (Buffered):

    A=9&B=1&B=2

    HTML web page ouput:

    A=9&B=1&B=2

  • With variable A specified in Request.QueryString

    ASP script command:

    <%= Request.QueryString("A") %>

    HTTP response output (Buffered):

    9

    HTML web page ouput:

    9

  • With variable B specified in Request.QueryString

    ASP script command:

    <%= Request.QueryString("B") %>

    HTTP response output (Buffered):

    1, 2

    HTML web page ouput:

    1, 2

  • With variable B specified in Request.QueryString().Count

    ASP script command:

    <%= Request.QueryString("B").Count %>

    HTTP response output (Buffered):

    2

    HTML web page ouput:

    2

  • Loop for all values in variable B specified in Request.QueryString() by count

    ASP script command:

    <%
    For i=1 to Request.QueryString("B").count
    Response.Write Request.QueryString("B")(i) & "<br />"
    Next
    %>

    HTTP response output (Buffered):

    1<br />
    2<br />

    HTML web page ouput:

    1
    2

  • Loop for all values in variable B specified in Request.QueryString() by item

    ASP script command:

    <%
    For Each item in Request.QueryString("B")
    Response.Write item & "<br />"
    Next
    %>

    HTTP response output (Buffered):

    1<br />
    2<br />

    HTML web page ouput:

    1
    2


©sideway

ID: 120200017 Last Updated: 7/2/2012 Revision: 0 Ref:

close

References

  1. Active Server Pages,  , http://msdn.microsoft.com/en-us/library/aa286483.aspx
  2. ASP Overview,  , http://msdn.microsoft.com/en-us/library/ms524929%28v=vs.90%29.aspx
  3. ASP Best Practices,  , http://technet.microsoft.com/en-us/library/cc939157.aspx
  4. ASP Built-in Objects,  , http://msdn.microsoft.com/en-us/library/ie/ms524716(v=vs.90).aspx
  5. Response Object,  , http://msdn.microsoft.com/en-us/library/ms525405(v=vs.90).aspx
  6. Request Object,  , http://msdn.microsoft.com/en-us/library/ms524948(v=vs.90).aspx
  7. Server Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms525541(v=vs.90).aspx
  8. Application Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms525360(v=vs.90).aspx
  9. Session Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms524319(8v=vs.90).aspx
  10. ASPError Object,  , http://msdn.microsoft.com/en-us/library/ms524942(v=vs.90).aspx
  11. ObjectContext Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms525667(v=vs.90).aspx
  12. Debugging Global.asa Files,  , http://msdn.microsoft.com/en-us/library/aa291249(v=vs.71).aspx
  13. How to: Debug Global.asa files,  , http://msdn.microsoft.com/en-us/library/ms241868(v=vs.80).aspx
  14. Calling COM Components from ASP Pages,  , http://msdn.microsoft.com/en-us/library/ms524620(v=VS.90).aspx
  15. IIS ASP Scripting Reference,  , http://msdn.microsoft.com/en-us/library/ms524664(v=vs.90).aspx
  16. ASP Keywords,  , http://msdn.microsoft.com/en-us/library/ms524672(v=vs.90).aspx
  17. Creating Simple ASP Pages,  , http://msdn.microsoft.com/en-us/library/ms524741(v=vs.90).aspx
  18. Including Files in ASP Applications,  , http://msdn.microsoft.com/en-us/library/ms524876(v=vs.90).aspx
  19. ASP Overview,  , http://msdn.microsoft.com/en-us/library/ms524929(v=vs.90).aspx
  20. FileSystemObject Object,  , http://msdn.microsoft.com/en-us/library/z9ty6h50(v=vs.84).aspx
  21. http://msdn.microsoft.com/en-us/library/windows/desktop/ms675944(v=vs.85).aspx,  , ADO Object Model
  22. ADO Fundamentals,  , http://msdn.microsoft.com/en-us/library/windows/desktop/ms680928(v=vs.85).aspx
close
IMAGE

Home 5

Business

Management

HBR 3

Information

Recreation

Hobbies 8

Culture

Chinese 1097

English 337

Reference 67

Computer

Hardware 149

Software

Application 198

Digitization 118

Numeric 19

Programming

Web 283

Unicode 494

HTML 65

CSS 58

ASP.NET 96

OS 389

DeskTop 7

Python 19

Knowledge

Mathematics

Formulas 8

Algebra 25

Number Theory 206

Trigonometry 18

Geometry 18

Calculus 67

Complex Analysis 21

Engineering

Tables 8

Mechanical

Mechanics 1

Rigid Bodies

Statics 92

Dynamics 37

Fluid 5

Fluid Kinematics 5

Control

Process Control 1

Acoustics 19

FiniteElement 2

Physics

Electric 27

Biology 1

Geography 1


Copyright © 2000-2020 Sideway . All rights reserved Disclaimers last modified on 06 September 2019