Reputation: 103358
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?
Upvotes: 9
Views: 6516
Reputation: 269388
They're checked in the following order:
QueryString
Form
Cookies
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
.
Upvotes: 19