Request() vs Request.QueryString()

别说谁变了你拦得住时间么 提交于 2019-12-01 00:10:00

问题


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:

  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.



来源:https://stackoverflow.com/questions/3178536/request-vs-request-querystring

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!