Thursday, December 5, 2013

Get Compile-Time View Errors in ASP.NET MVC

ASP.NET MVC developers generally face an issue with compiling their views.  The errors are not reported when compiling views and they eventually turn out to be "Yellow Screen Of Death" issues from client.  Below are the steps to enable compilation errors in views:

  1. Right-click on your project file in Visual Studio’s Solution Explorer and choose Unload Project.
  2. Right-click the project file again and choose Edit YourProject.csproj.
  3. Look for a node called <MvcBuildViews> in the first <PropertyGroup> node (the one without any other attributes). If it’s not there, add it.
  4. Add or update the value inside the <MvcBuildViews> node to true. When you’re done it should look like this: 

    <
    MvcBuildViews>true</MvcBuildViews
  5. Save the project file changes.
  6. Right-click the project file in Solution Explorer one last time and select Reload Project.

No comments: