加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

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

发布时间:2020-12-16 07:37:03 所属栏目:asp.Net 来源:网络整理
导读:我一直在谷歌上搜索几个小时.但仍然无法得到答案.我需要在剃刀视图中获取查询字符串参数. 这是我的代码: if @(Request.Query["value"]=="P"){ a href="@Url.Action("Index","Staff",new { status = "A"})"strongActive (@ViewData["activeCount"]) /strong/
我一直在谷歌上搜索几个小时.但仍然无法得到答案.我需要在剃刀视图中获取查询字符串参数.

这是我的代码:

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

               }

但我收到错误“当前上下文中不存在名称’请求’”

截图

enter image description here


谁有解决方案?谢谢

解决方法

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读