当前上下文中不存在名称“ViewBag" [英] The name 'ViewBag' does not exist in the current context
问题描述
我正在尝试在我的应用程序中使用 ViewBag,我拥有所有最近的 dll、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:
当前上下文中不存在名称‘ViewBag’"
"The name 'ViewBag' does not exist in the current context"
我什至卸载并重新安装了 MVC 3,但没有任何变化.
I have even uninstalled and then re-installed MVC 3 and yet there is no change.
另外,我不相信 dll 会出现在 GAC 中.
Also, I do not believe that the dll's are showing up in the GAC.
我的问题是什么?或者如何将dll添加到GAC?
What might be my problem? Or how to add the dll's to the GAC?
推荐答案
您需要将特定于 MVC 的 Razor 配置添加到您的 web.config.请参阅此处:未找到 Razor HtmlHelper 扩展(或其他视图命名空间)
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
使用 MVC 3 升级工具可自动确保您拥有正确的配置值.
Use the MVC 3 upgrade tool to automatically ensure you have the right config values.
这篇关于当前上下文中不存在名称“ViewBag"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!