我有一个MVC 3项目,我们在Visual Studio 2010&2012年。自从我们进入2013年以来,它向我们展示了错误。
Error 5 The name 'ViewBag' does not exist in the current context c:workspaceprojectxyz.cshtml 4 5 EnyaCMS
他们对ViewBag没有问题。我调试了这个项目,它在Chrome浏览器中运行良好。另一个问题是
Error 10 'System.Web.WebPages.Html.HtmlHelper' does not contain a definition for 'Partial' and no extension method 'Partial' accepting a first argument of type 'System.Web.WebPages.Html.HtmlHelper' could be found (are you missing a using directive or an assembly reference?) c:workspaceanotherindex.cshtml 33 7
有人告诉我如何解决这个问题。我认为这个项目没有问题,因为它在浏览器中运行良好。如何在我的项目视图中包含ViewBag和其他问题的引用。
前几天,在尝试升级MVC项目后,我在VS2013中遇到了这个问题。
出现此问题的原因是,新的VS项目被设置为不兼容的.Net Framework版本-我认为,默认情况下,它被设置为v4.0,而我引用的nuget包适用于较新的.Net版本。
我将.Net目标更改为v4.5.1,删除了所有过期的nuget包/有问题的引用,并重新引用了它们。