Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compile cshtml before runtime

I believe I read somewhere there is a setting in one of the project files that will allow you to compile the .cshtml files when building your Visual Studio project.

Just getting started with MVC/Razor/Query Mobile, and am getting annoyed with the "Error loading page" when I have an error in a code block inside a .cshtml file

like image 608
FatFingers Avatar asked Nov 20 '12 20:11

FatFingers


People also ask

Do Cshtml files get compiled?

cshtml extension are compiled at both build and publish time using the Razor SDK. Runtime compilation may be optionally enabled by configuring your project.

How do I create a Cshtml file?

Go to solution explorer => Views Folder => Right-click on “Home” Folder >> go to “Add” >> Click on [New Item] as follow. Select MVC 5 View Page with Layout(Razor) from "Add New Item" window and provide the required name like "ViewPageWithLayout. cshtml" click on "Add" button as follow.


1 Answers

Set <MvcBuildViews>true</MvcBuildViews> in the <PropertyGroup> element of your .csproj file.

like image 152
Levi Botelho Avatar answered Sep 29 '22 09:09

Levi Botelho