且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

当前上下文中不存在名称“ViewBag”

更新时间:2023-02-16 15:26:12

您需要将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.