2016-01-28 78 views
2

我一直在搜索幾個小時。但仍然無法得到答案。我需要在剃刀視圖中獲取查詢字符串參數。Asp.net 5 mvc 6獲取查詢字符串來查看

這裏是我的代碼:

   if @(Request.Query["value"]=="P"){ 

        <a href="@Url.Action("Index", "Staff",new { status = "A"})"><strong>Active (@ViewData["activeCount"]) </strong></a> &nbsp; 
        <a href="@Url.Action("Index", "Staff",new { status = "I" })">In-Active (@ViewData["inActiveCount"])</a>&nbsp; 
        <a href="@Url.Action("Index", "Staff",new { status = "D" })">Delete (@ViewData["deleteCount"])</a>&nbsp; 
       }else{ 
        <a href="@Url.Action("Index", "Staff",new { status = "A"})">Active (@ViewData["activeCount"])</a> &nbsp; 
        <a href="@Url.Action("Index", "Staff",new { status = "I" })"><strong>In-Active (@ViewData["inActiveCount"])<strong></a>&nbsp; 
        <a href="@Url.Action("Index", "Staff",new { status = "D" })">Delete (@ViewData["deleteCount"])</a>&nbsp; 

       } 

,但我得到的錯誤

截圖 enter image description here 任何人有解決方案「名稱‘請求’不存在當前上下文存在」?謝謝

+0

您是否嘗試過使用Context.Request.Query [ 「值」],而不是僅僅Request.Query [ 「價值」]? – digiliooo

+0

yes.thanks your answer – user998405

+0

當然,我很高興它爲你工作 – digiliooo

回答

8

使用Context.Request.Query["value"]而不是Request.Query["value"]

+0

驚訝多久才找到這個答案 –

0

是的終於可以。那麼答案是Context.Request.Query [ 「價值」