簡體   English   中英

MVC 4 IntelliSense在Visual Studio 2010中無法在Razor中運行

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

我使用Visual Studio 2010與ASP.NET MVC4和IntelliSense for Razor語法在應用程序的視圖中不適合我。

我能做什么?

也引用自

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

在安裝MVC 4 Beta之后,IntelliSense打破了Visual Studio 2010中MVC 3應用程序中的Razor視圖。這在發行說明中有說明,但沒有人會讀取這些內容。

這次問題的解決方案實際上列在那些發行說明中。 您需要明確說明web.config中引用的版本號。

添加新的appSettings-entry以明確說明要使用的WebPages版本:

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

然后你必須編輯.csproj文件,你需要在其中找到對System.Web.WebPages和System.Web.Helpers的引用,並確保它們具有如下的顯式版本號:

例如:

<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" />

-

希望這將在MVC 4的最終版本中得到解決,或者可能的情況是Razor v1中對版本的引用在MVC 3項目中過於寬松。

還有一個類似的問題MVC 3 Visual Studio 2010 Razor Model intellisense無法正常工作

您還可能需要安裝VS 2010 SP1

編輯

另請參閱此頁面上的必需更新
http://www.asp.net/whitepapers/mvc4-release-notes#_Toc303253815

對我來說問題是在Views \\ web.config中我引用了舊版本的mvc。 (我從V4遷移了我的項目)我更新了版本並重新啟動,我現在有智能感知

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM