当前上下文中不存在名称“ViewBag” [英] The name 'ViewBag' does not exist in the current context

查看:633
本文介绍了当前上下文中不存在名称“ViewBag”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的应用程序中使用ViewBag,我有所有最新的DLL,最新版本的MVC 3,但是我仍然得到错误:名称ViewBag不存在于当前的上下文。



我甚至卸载,然后重新安装MVC 3,但没有变化。



此外,我不相信dll在GAC中显示。



任何人知道我的问题可能是什么?或者如何将dll添加到GAC?

解决方案

您需要将MVC特定的Razor配置添加到您的web.config中。请参阅: Razor HtmlHelper扩展(或视图的其他命名空间)未找到



使用 MVC 3升级工具,以自动确保您具有正确的配置值。


I am trying to use ViewBag in my application, I have all of the recent dlls, the latest version of MVC 3, but yet I am still getting the Error: "The name 'ViewBag' does not exist in the current context".

I have even uninstalled and then re-installed MVC 3 and yet there is no change.

Also, I do not believe that the dll's are showing up in the GAC.

Any one know what my problem might be? Or how to add the dll's to the GAC?

解决方案

You need to add the MVC-specific Razor configuration to your web.config. See here: Razor HtmlHelper Extensions (or other namespaces for views) Not Found

Use the MVC 3 upgrade tool to automatically ensure you have the right config values.

这篇关于当前上下文中不存在名称“ViewBag”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆