我設置在我的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指向第一個請求。那麼 - 如何獲取子請求的查詢字符串數據?
謝謝! /Victor
您在'new {Foo =「Bar」}''中缺少一個報價。 – 2012-01-05 12:42:16
謝謝Pankaj,固定。 – Victor 2012-01-09 10:01:07