Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Request() vs Request.QueryString()

Tags:

asp.net

vb.net

I have recently started using Request("key") instead of Request.QueryString("key") to access my querystring values. However I have read that:

Gets the specified object from the System.Web.HttpRequest.Cookies, System.Web.HttpRequest.Form, System.Web.HttpRequest.QueryString, System.Web.HttpRequest.ServerVariables

Therefore, if I have a querystring key and cookie key which are the same, which value is returned?

like image 279
Curtis Avatar asked Jul 05 '10 09:07

Curtis


People also ask

What is the use of request QueryString and Request form?

Form, the Web server parses the HTTP request body and returns the specified data. If your application requires unparsed data from the form, you can access it by calling Request. Form without any parameters. The QueryString collection retrieves the values of the variables in the HTTP query string.

What is request QueryString ()?

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. QueryString(parameter).

What is request QueryString in VB net?

A Query String collection is a parsed version of the QUERY_STRING variable in the Server Variables collection. It enable us to retrieve the QUERY_STRING variable by name. When we use parameters with Request. QueryString, the server parses the parameters sent to the request and returns the effective or specified data.

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

They're checked in the following order:

  1. QueryString
  2. Form
  3. Cookies
  4. ServerVariables

The search is short-circuited, so as soon as a matching key is found the value is returned.

So, to answer your question, a matching QueryString item takes precedence over Cookies.

like image 189
LukeH Avatar answered Nov 14 '22 04:11

LukeH