HttpRequestインデクサーの検索順序
-
06-07-2019 - |
質問
Request [key]を介してRequestのアイテムに単純なインデックスを作成すると、 4つの場所。順序は何ですか?そのページの「Cookies、ServerVariables、Form、QueryString」で誰かが推測します。誰もが確かに知っていますか?ドキュメンテーションはボーナスです:)
解決
public string this [string key] {get; }
宣言タイプ:System.Web.HttpRequestアセンブリ:System.Web、 バージョン= 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;
}
}
所属していません StackOverflow