Razor 3 in Visual Studio 2012

11,801

Solution 1

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

Solution 2

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.

Share:
11,801

Related videos on Youtube

Jeremi Stadler
Author by

Jeremi Stadler

C# Guru, loves backend code and Game Dev

Updated on September 14, 2022

Comments

  • Jeremi Stadler
    Jeremi Stadler over 1 year

    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

  • Eric Bishard
    Eric Bishard over 10 years
    I have had to do this once. It may be the problem, please let me know if it doesn't work and maybe I can recommend something else. BTW...I tried posting this as a comment and not a ANSWER. Not sure why I couldn't do that.
  • Jeremi Stadler
    Jeremi Stadler over 10 years
    The "All Languages" tab does not have any instellisence options and the C# tab had everything correcty set (I think)
  • Eric Bishard
    Eric Bishard over 10 years
    Damn. Did you look at the related posts?
  • Jeremi Stadler
    Jeremi Stadler over 10 years
    To fix it I created a new project in VS 2013 and migrated everything