Compile MVC View and mvcview
By default, the View page of MVC does not participate in compilation. After the view corresponds to the model, the view can also be compiled, or the server code on the page is incorrect.
So how can we make errors in the View fail during compilation. After finding the method, the local MVC5.0 is applicable, and other versions are not tried.
Method:
1. Modify the. csproj project file and open it in txt notepad.
2. Find<Project> the node is in<PropertyGroup> Add at the beginning
<MvcBuildViews>true</MvcBuildViews>。
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <MvcBuildViews>true</MvcBuildViews> </PropertyGroup>
3. Cancel at the bottom of the project file<Target Name = "AfterBuild"> comment and add the following attributes:
<Target Name="AfterBuild" Condition="'$(MvcBuildViews)'=='true'"> <AspNetCompiler VirtualPath="temp" PhysicalPath="$(ProjectDir)\..\$(ProjectName)" /></Target>
Done. Test Results
No error is reported before the project is modified, and compilation is normal;
After modifying the project:
After you accidentally modify the page or the background model and general method, you will be able to know which pages are associated.
There is also a way to introduce RazorGenerator in nuget.
Reference: http://stackoverflow.com/questions/383192/compile-views-in-asp-net-mvc