当发送特定的查询字符串参数时,我正在我的 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,这意味着 HttpContext.Current 指向第一个请求。那么 - 如何获取子请求的查询字符串数据?
谢谢!/胜利者