asp.net-mvc-3 – ViewBag- MVC3-ASP.NET
发布时间:2020-12-15 22:36:13 所属栏目:asp.Net 来源:网络整理
导读:我想在控制器中为ViewBag分配一个值,以便以后在View中使用,它会抱怨以下错误. 像这样在Controller中分配值. ViewBag["isAdmin"]=true; 错误: Cannot apply indexing with [] to an expression of type 'System.Dynamic.DynamicObject' 以前有人有这个吗?
我想在控制器中为ViewBag分配一个值,以便以后在View中使用,它会抱怨以下错误.
像这样在Controller中分配值. ViewBag["isAdmin"]=true; 错误: Cannot apply indexing with [] to an expression of type 'System.Dynamic.DynamicObject' 以前有人有这个吗? 解决方法
您只需要ViewBag.isAdmin = true.您可以访问的是
if(ViewBag.isAdmin) { //do stuff } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc – 从控制器中的formcollection中找到隐藏字段
- asp.net-mvc – 为什么IIS / ASP.Net / MVC3将max-age设置为
- asp.net-web-api – 在Windows服务中使用OWIN托管WebAPI
- asp.net-mvc – 在EF 6中设置命令超时
- Asp.net验证网络文件地址是否有效的方法
- asp.net – HMACSHA1.ComputeHash()线程安全问题
- ASP.NET AJAX Call Web Service , Return JSON Format Stri
- asp.net-mvc-4 – GoogleOauth2问题获取Internal Server 50
- asp.net-mvc – 如何从视图中检索传递给我的自定义EditorFo
- .net – 在黄屏死亡的地方有执行吗?
推荐文章
站长推荐
- 如何制作100%宽度的asp.net菜单
- 在Asp.Net中启用Secure中的HTTPOnly
- asp.net-mvc-2 – Html.Hidden()插入错误的值
- asp-classic – 经典ASP页面可以在Azure中运行吗
- asp.net-mvc – MicrosoftMvcValidation.js VS j
- asp.net – 为什么HttpUtility.UrlPathEncode标记
- IIS 7应用程序池标识权限
- asp.net-mvc – 如何设置html.EditorFor helper的
- asp.net-mvc – 如何跳过ActionFilter的操作执行
- asp.net – 如何强制netwtonsoft json序列化程序
热点阅读