问题
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?
回答1:
They're checked in the following order:
QueryStringFormCookiesServerVariables
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.
来源:https://stackoverflow.com/questions/3178536/request-vs-request-querystring