If you do a simple index into Request's items via Request[key], it looks in 4 locations. What's the order? Someone makes a guess on that page at "Cookies, ServerVariables, Form and QueryString". Does anyone know for sure? Documentation would be a bonus :)
+1
A:
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;
}
}
rick schott
2009-10-27 19:20:12
+1
A:
This is from an ASP site, but it still applies to ASP.NET:
All request object variables can be accessed directly by calling Request(variable) without the collection name. In this case, the Web server searches the collections in the following order:
- QueryString
- Form
- Cookies
- ClientCertificate
- ServerVariables
Tim S. Van Haren
2009-10-27 19:23:08
Reflector says that "ClientCertificate" isn't searched in .Net 2.0.
David
2009-10-27 19:34:40