Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 393
Jeremi Stadler Avatar asked Oct 23 '13 20:10

Jeremi Stadler


People also ask

How do I add a new Razor page in Visual Studio?

Create a Razor Pages web appStart Visual Studio 2022 and select Create a new project. In the Create a new project dialog, select ASP.NET Core Web App, and then select Next.

What is Razor in Visual Studio?

Razor syntax is a simple programming syntax for embedding server-based code in a web page. In a web page that uses the Razor syntax, there are two kinds of content: client content and server code.

Does .NET framework support Razor pages?

Introduced as part of ASP.NET Core, and now included in . NET 5, ASP.NET Razor Pages is a server-side, page-focused framework that enables building dynamic, data-driven web sites with clean separation of concerns.


2 Answers

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

like image 59
Aaron Stainback Avatar answered Nov 07 '22 08:11

Aaron Stainback


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.

like image 27
Ardavan Dejpanah Avatar answered Nov 07 '22 10:11

Ardavan Dejpanah