Jeremi Stadler
Jeremi Stadler

Reputation: 2637

Razor 3 in Visual Studio 2012

I've updated all nuget packages and got the new MVC 5.0 package and Razor 3.0 Since then instellisence and syntax highlighting for all .cshtml files has stopped working

System.Web.WebPages.Razor is version: 3.0.0.0
System.Web.dll is version 4.0.0.0
System.Web.Mvc is version 5.0.0.0

Im running Visual Studio 2012 with Update 3

Also tried making a new MVC 4 project and doing a Nuget Update all with the same result: Razor Intellisence stops working.

Applied the upgrade guide without any success: http://www.asp.net/mvc/tutorials/mvc-5/how-to-upgrade-an-aspnet-mvc-4-and-web-api-project-to-aspnet-mvc-5-and-web-api-2

Upvotes: 12

Views: 11874

Answers (4)

seebiscuit
seebiscuit

Reputation: 5053

Since all the answers posted at the time of writing this are from 2013, and there's still some of us unfortunate enought to use VS2012, I want to post a direct link to the WebTools2013 package that will, amongst other things, enable Razor 3 support:

Link to direct download: WebTools2013 for Visual Studio 2012

I was forced to use link since the Web Platform Installer can no longer find the Razor 3 package.

Hope this helps someone else!!

Upvotes: 0

Ardavan Dejpanah
Ardavan Dejpanah

Reputation: 106

how to upgrade an aspnet mvc4 and webapi project to aspnet mvc5 and web api2

In VS2013 Preview, we released new Razor V3 runtime and design time Engine to support MVC5 and Razor V3 website’s runtime and design time behavior. Unlike Razor V2 runtime and design time, VS2013 did not GAC these binaries. Instead, the binaries are installed in the project bin folder when corresponding NuGet package is installed, and in “%ProgramFiles (x86)%\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\Web\Razor\v3.0” to support design time.

As in VS2012 to determine which razor v1/v2 design time dlls to load, VS 2013 preview first use web.config file key to determine the design time dll version to load for editing webpages. For example, by default, MVC5 project contains , VS will load Razor V3 dlls to edit the project’s webpage files (i.e. cshtml or vbhtml files) .

If the key is missing from web.config file such as default Razor V2/V3 website, VS will use bin directory’s razor dll version to determine the design time razor engine dll to load.

Since Razor v1 is no longer ships with VS2013 preview, if a single webpage file (i.e. cshtml or vbhtml files) is opened without bin directory nor web.config setting, VS 2013 preview will simply load the webpage as a plain text file. Updated 10/9/2013: In VS2013 RC and RTW, VS will open the single webpage file using the highest Razor version on the box.

You can verify these behavior by debugging into the Visual Studio process and check the module window, filter with razor keyword.

Upvotes: 2

Aaron Stainback
Aaron Stainback

Reputation: 3657

Microsoft has released an update for this, Web Tools 2013.1 for VS2012.

http://blogs.msdn.com/b/webdev/archive/2013/11/18/announcing-release-of-asp-net-and-web-tools-2013-1-for-visual-studio-2012.aspx

Upvotes: 14

Eric Bishard
Eric Bishard

Reputation: 5341

Have you tried manually resetting intellisense?

To re-enable intellisense manually go into your Tools -> Options -> Text Editor -> All Languages + C#

Upvotes: 0

Related Questions