Saturday, July 13, 2013

Compile time view checking for ASP.NET MVC.

While developing an ASP.NET MVC application, you need to create lots of views. At that time it does not compile the view. So if you have some typo in your view like namespace or any where you will get to know when you load that view in browser. At that time ASP.NET Complier will compile the complete view. 

We all are humans and we tends to make spelling mistakes and sometimes it a productivity loss when you create a very big view or complicated view. So I was searching on internet that whether there is a tool available to compile view also. After digging into it. I have found that there is a setting where we can tell whether its compile view or not. So once you enable that settings It will also compile views.

In project template there is a setting MVCBuildViews like following and it will also compile the views.


By default it will be false so views will not compile but when make it true like it will also compile views.


Once you have enabled it you will get your view compiled and that’s way you can avoid any typo or mistakes in your view at compile time.

Let’s see how we can do it. First open the solution folder via Right Click solution and ‘Open in file explorer.


Right click the project file and open in text editor like notepad++


Find ‘MvcBuildViews’ and make it true’ and reload project.


Now suppose you have made typo with namespace and compile that project. It will give compile error.


That’s it. You can save lots of time via getting all this error at Compile Time. Hope you like it. Stay tuned for more.


Your feedback is very important to me. Please provide your feedback via putting comments.

Support this blog-Buy me a coffee

Buy me a coffeeBuy me a coffee
Search This Blog
Subscribe to my blog


My Mvp Profile
Follow us on facebook
Blog Archive
Total Pageviews