In this post, we are going to discuss about how to capture “view” errors atย compile time. By default, ASP.NET MVC projects won’t compile the views onย the building process of our application. But don’t think Visual studio not handle this. As per below screen shot, it’s showingย views error as warning in theย Error List window, but we won’t consider the warning while running the application.ย
All things are handling her. But many of us really won’t check this warning, as shown above. What we can do here is a fairly simple action to get this blow up on compile time. Let we discuss details about this.
STEP 1:
Right-click on your project’sย solution explorer and click Unload Project as shown in below image
STEP 2: After project unloaded,
After the project unloaded, right-click the project and choose Edit “Your project name” (. csproj) and MvcBuildViews node from false to true (for handlingthe error in compile time) and save the file.
STEP 3:
Reload the project and build the solution. Now we can see the “0 succeed , 1 failed” in the output window.
Your views will now be built at compile -time and you will get syntax errors from any mistakes in your Razor syntax or breaking changes to your model, and you ll get them long before your code makes it in front of users.