如果您通过 Request[key] 对 Request 的项目进行简单索引,它会在 4 locations 中查找.顺序是什么?有人在该页面上的“Cookies、ServerVariables、Form 和 QueryString”处进行了猜测。有人有确切消息么?文档将是一个奖励:)
最佳答案
public string this[string key] { get; }
Declaring Type: System.Web.HttpRequest Assembly: System.Web, Version=2.0.0.0
public string this[string key]
{
get
{
string str = this.QueryString[key];
if (str != null)
{
return str;
}
str = this.Form[key];
if (str != null)
{
return str;
}
HttpCookie cookie = this.Cookies[key];
if (cookie != null)
{
return cookie.Value;
}
str = this.ServerVariables[key];
if (str != null)
{
return str;
}
return null;
}
}
关于c# - HttpRequest 索引器的搜索顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1632969/