特定のクエリ文字列引数が送信されたときにhtmlタグにクラスを設定していますが、現在は次のようにしています(Razorビューマスターページ):
@if (HttpContext.Current.Request.QueryString.AllKeys.Contains("Foo") && HttpContext.Current.Request.QueryString["Foo"] == "Bar") {
//Do something when Foo=Bar (like http://server/route?Foo==Bar)
<html class="bar-class">
}
else {
//Normal html tag
<html>
}
通常のリクエストでは正常に機能しますが、RenderActionを使用してページを呼び出す場合は機能しません。
//Other view, the one requested by the user
@Html.RenderAction("Index", "Route", new {Foo="Bar"})
周りを見回した後、実際のHttpContextは1つしかないことに気付きました。これは、HttpContext.Currentが最初のリクエストを指していることを意味します。では、サブリクエストのクエリ文字列データを取得するにはどうすればよいですか?
ありがとう!/ビクター