Blog: 2015 August

Precompile ASP.NET MVC Razor views in Release mode to find errors at compile time

A problem we often face when developing ASP.NET MVC applications is that errors in Razor views are only detected at runtime while browsing the site. This is because the Razor views are not compiled until they are requested by the browser. To avoid this problem, you can prebuild the views by adding the MvcBuildViews tag to your .csproj file: <?xml version="1.0" encoding="utf-8"?> <Project ...> ... <PropertyGroup> ... <MvcBuildViews>true</MvcBuildViews> ... There are two problems with this approach: The build process takes much longer You cannot change the views when debugging the running application To avoid these problems and still be able […] Read more...

Tags: , , , ,

  Page 1 of 1