我一直在搜索幾個小時。但仍然無法得到答案。我需要在剃刀視圖中獲取查詢字符串參數。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>
<a href="@Url.Action("Index", "Staff",new { status = "I" })">In-Active (@ViewData["inActiveCount"])</a>
<a href="@Url.Action("Index", "Staff",new { status = "D" })">Delete (@ViewData["deleteCount"])</a>
}else{
<a href="@Url.Action("Index", "Staff",new { status = "A"})">Active (@ViewData["activeCount"])</a>
<a href="@Url.Action("Index", "Staff",new { status = "I" })"><strong>In-Active (@ViewData["inActiveCount"])<strong></a>
<a href="@Url.Action("Index", "Staff",new { status = "D" })">Delete (@ViewData["deleteCount"])</a>
}
,但我得到的錯誤
截圖 任何人有解決方案「名稱‘請求’不存在當前上下文存在」?謝謝
您是否嘗試過使用Context.Request.Query [ 「值」],而不是僅僅Request.Query [ 「價值」]? – digiliooo
yes.thanks your answer – user998405
當然,我很高興它爲你工作 – digiliooo