开发者

Razor intellisense and code formatting with MVC 4

I have just integrated MVC into my Asp.Net website project.

Its working, but my Razor code is missing formatted as code (e.g. yellow background for the @ character.

Additionally there is no intellisense:

Razor intellisense and code formatting with MVC 4

Here are my MVC related references from web.config

<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.WebPages, Version=2.0.0.0, Culture=neu开发者_运维技巧tral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>


Please try building the project and see if that helps.


Check the Web.config under the View folder

configSections->sectionGroup and sections. The Version numbers should be 2.0.0.0 All other version in the file should be 4.0.0.0


I'm not sure what fixed this:

I uninstalled all versions of MVC framework, re-installed MVC 4, and upgraded ReSharper to v 6

However, I am still not getting syntax highlighting ( the @ character is not yellow)


On december 5 2013 i installed the latest updates for visual Studio 2012. Right after that, the cshtml in my mvc4 project went like it apprears in Notepad: not good!

I uninstalled via the package manager, MVC4, restarted VS2012 and installed it again. After that everything looked right again: the syntax highlighting worked again. I use VS2012 professional.


For me, the .cshtml file was not included in the project. I checked in Solution explorer, it was not showing under my View folder.

I chose "Show All files" at top of solution explorer buttons. My cshtml file started showing but icon in dotted lines, so right click on it >> Include in the project.

and building the solution, includes my cshtml file in the project. and now everything's works fine.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜