Request()与Request.QueryString() [英] Request() vs Request.QueryString()

查看:61
本文介绍了Request()与Request.QueryString()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始使用 Request("key")而不是 Request.QueryString("key")来访问我的查询字符串值.但是我读过:

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

从System.Web.HttpRequest.Cookies获取指定的对象,System.Web.HttpRequest.Form,System.Web.HttpRequest.QueryString,System.Web.HttpRequest.ServerVariables

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

因此,如果我有一个相同的querystring键和cookie键,则返回哪个值?

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

推荐答案

按以下顺序检查它们:

  1. QueryString
  2. 表格
  3. Cookies
  4. ServerVariables

搜索被短路,因此一旦找到匹配的键,则返回值.

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

因此,为回答您的问题,匹配的 QueryString 项优先于 Cookies .

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

这篇关于Request()与Request.QueryString()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆