Asp.net 5 mvc 6 获取要查看的查询字符串

Asp.net 5 mvc 6 get query string to view

我在谷歌上搜索了几个小时。但仍然无法得到答案。我需要在剃刀视图中获取查询字符串参数。

这是我的代码:

              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;

               }

但我收到错误消息“名称 'Request' 在当前上下文中不存在

截图 有人有解决办法吗?谢谢

是的,你终于可以了。答案是Context.Request.Query ["value"]

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