Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Request versus Request.QueryString

What is the difference between these two in VBScript:

Request("startDate")

Request.QueryString["startDate"]

And where is Request("startDate") documented? I don't see this usage here:

http://www.w3schools.com/asp/asp_ref_request.asp

like image 549
Baz Avatar asked Feb 08 '12 15:02

Baz


People also ask

What is the use of request QueryString and Request form?

It enables you to retrieve the QUERY_STRING variable by name. The value of Request. QueryString(parameter) is an array of all of the values of parameter that occur in QUERY_STRING. You can determine the number of values of a parameter by calling Request.

What is request QueryString in asp net?

The ASP Request. QueryString Collection is used to get the value of the variable that will be stored in the HTTP query string from the URL.

What is a QueryString used for?

The QueryString collection is used to retrieve the variable values in the HTTP query string. The line above generates a variable named txt with the value "this is a query string test". Query strings are also generated by form submission, or by a user typing a query into the address bar of the browser.

What is QueryString in MVC?

Generally, the query string is one of client-side state management techniques in ASP.NET in which query string stores values in URL that are visible to Users. We mostly use query strings to pass data from one page to another page in asp.net mvc. In asp.net mvc routing has support for query strings in RouteConfig.


1 Answers

The official documentation for the Request object in ASP classic is here: http://msdn.microsoft.com/en-us/library/ms524948%28VS.90%29.aspx

Quoting the relevant part for this question:

All variables can be accessed directly by calling Request(variable) without the collection name. In this case, the Web server searches the collections in the following order:

  • QueryString
  • Form
  • Cookies
  • ClientCertificate
  • ServerVariables

If a variable with the same name exists in more than one collection, the Request object returns the first instance that the object encounters.


EDIT: AnthonyWJones made a great comment on the question: Avoid using the Request("name") syntax. In fact, this is mentioned in the documentation link above:

It is strongly recommended that when referring to members of a collection the full name be used. For example, rather than Request.("AUTH_USER") use Request.ServerVariables("AUTH_USER"). This allows the server to locate the item more quickly.

like image 199
Cheran Shunmugavel Avatar answered Oct 06 '22 14:10

Cheran Shunmugavel