Quantcast
Channel: The Wired Bedouin » wiredbedouin
Viewing all articles
Browse latest Browse all 10

Compiling Views in MVC4

$
0
0

By default, any typo or mistake in MVC razor views will only be detected during execution.. However, you can enable compiling of views and detect those errors earlier in the development cycle.

Just open your project file (.csproj) as text (unload your project first), and find the < MvcBuildViews> and change its value to true:

<MvcBuildViews>true</MvcBuildViews>

Beware that compilation time will be increased (almost double in my case). You may also get a weird “Unrecognized attribute ‘xmlns:xdt’on the web.config” error during compilation (especially after switching between build configurations ). To work around it, delete the \obj folder in your project folder, or use the pre-build step described in here.

A pre-build step that worked for me was:

del $(ProjectDir)obj\* /F /S /Q


Viewing all articles
Browse latest Browse all 10

Trending Articles