Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/279.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# System.Web.Mvc版本更改时出现Razor视图错误_C#_Asp.net_Asp.net Mvc_Asp.net Mvc 4_Razor - Fatal编程技术网

C# System.Web.Mvc版本更改时出现Razor视图错误

C# System.Web.Mvc版本更改时出现Razor视图错误,c#,asp.net,asp.net-mvc,asp.net-mvc-4,razor,C#,Asp.net,Asp.net Mvc,Asp.net Mvc 4,Razor,从GitHub中提取的同一个ASP.NET MVC项目在我朋友的PC中编译时没有任何错误,但在我的PC中,仅在Razor视图文件(.cshtml)中我收到多个错误,如: The name 'ViewBag' does not exist in the current context The name 'Scripts' does not exist in the current context The name 'Styles' does not exist in the current con

从GitHub中提取的同一个ASP.NET MVC项目在我朋友的PC中编译时没有任何错误,但在我的PC中,仅在Razor视图文件(.cshtml)中我收到多个错误,如:

The name 'ViewBag' does not exist in the current context
The name 'Scripts' does not exist in the current context
The name 'Styles' does not exist in the current context
因为我认为它是关于配置文件的,所以我删除并克隆了这个项目,但仍然是一样的。不过,该项目将运行良好。但由于这个问题,我无法在开发中获得适当的智能感知


更新:

出于某种奇怪的原因,如果我在电脑中将
System.Web.Mvc
版本更改为
5.0.0.0
,那么视图中的错误就会消失

<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

但是为什么呢


非常感谢您的帮助。

?如果
web.config
出现问题,那么它也不应该在我朋友的电脑上工作。请尝试重新启动visual studio,删除
.user
.suo
文件,及rebuild@YuliamChandra存在
.user
文件,删除
.suo
和重建不起作用。这是
web.config
错误或目标框架错误。右键单击项目的属性,将目标框架更改为应该更改的框架。