简体   繁体   English

MVC 4 IntelliSense在Visual Studio 2010中无法在Razor中运行

[英]MVC 4 IntelliSense is not working in Razor in Visual Studio 2010

I am using Visual Studio 2010 with ASP.NET MVC4 and the IntelliSense for Razor syntax is not working for me in the views for the application. 我使用Visual Studio 2010与ASP.NET MVC4和IntelliSense for Razor语法在应用程序的视图中不适合我。

What can I do? 我能做什么?

Also Quoting from 也引用自

http://sebnilsson.com/1091244048/making-mvc-3-razor-intellisense-work-after-installing-mvc-4-beta/ http://sebnilsson.com/1091244048/making-mvc-3-razor-intellisense-work-after-installing-mvc-4-beta/

After installing the MVC 4 Beta the IntelliSense breaks for Razor-views in MVC 3-applications in Visual Studio 2010. This is stated in the release-notes, but nobody usually reads those. 在安装MVC 4 Beta之后,IntelliSense打破了Visual Studio 2010中MVC 3应用程序中的Razor视图。这在发行说明中有说明,但没有人会读取这些内容。

This time the solution to the problem are actually listed in those release-notes. 这次问题的解决方案实际上列在那些发行说明中。 You need to the explicitly state the version-numbers of the references in your web.config. 您需要明确说明web.config中引用的版本号。

Add a new appSettings-entry for explicitly stating the version of WebPages to use: 添加新的appSettings-entry以明确说明要使用的WebPages版本:

 <appSettings>
     <add key="webpages:Version" value="1.0.0.0"/>
     <!-- ... --> 
 </appSettings>

Then you have to edit your .csproj-file, where you need to find your references to System.Web.WebPages and System.Web.Helpers and makes sure they have the explicit version-numbers like this: 然后你必须编辑.csproj文件,你需要在其中找到对System.Web.WebPages和System.Web.Helpers的引用,并确保它们具有如下的显式版本号:

eg: 例如:

<Reference Include="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"/>  

<Reference Include="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />

-- -

Hopefully this will be resolved in the final version of MVC 4 or maybe the case is that the references to versions in Razor v1 were just too loose in MVC 3-projects. 希望这将在MVC 4的最终版本中得到解决,或者可能的情况是Razor v1中对版本的引用在MVC 3项目中过于宽松。

Also a similar question MVC 3 Visual Studio 2010 Razor Model intellisense not working 还有一个类似的问题MVC 3 Visual Studio 2010 Razor Model intellisense无法正常工作

Also you may need to install VS 2010 SP1 . 您还可能需要安装VS 2010 SP1

Edit : 编辑

Also see Required updates on this page 另请参阅此页面上的必需更新
http://www.asp.net/whitepapers/mvc4-release-notes#_Toc303253815 http://www.asp.net/whitepapers/mvc4-release-notes#_Toc303253815

The problem for me came that in Views\\web.config i was referencing an older version of mvc. 对我来说问题是在Views \\ web.config中我引用了旧版本的mvc。 (I migrated my project from V3 from V4) I updated the version and restarted and i have intellisense now (我从V4迁移了我的项目)我更新了版本并重新启动,我现在有智能感知

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM