razor syntax with errors compiles when it should not compile
razor syntax with errors compiles when it should not compile
This is by design. The build of of MVC views is disabled by default. You can enable the build of your MVC views in Visual Studio like that:
- Right click on your project in Visual Studio
- Unload project
-
Edit project
-
Change the value for
MvcBuildViews
from false to true<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
...
<MvcBuildViews>true</MvcBuildViews>
...
-
Reload project
Next time you compile and there are errors in your MVC views, it will not compile. The downside is, the compilation process will take longer.
Update
Here is an answer on SO, explaining how to avoid the error:
It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS
Compile Views in ASP.NET MVC
回答1
From the readme word doc for RC1 (not indexed by google)
ASP.NET Compiler Post-Build Step
Currently, errors within a view file are not detected until run time. To let you detect these errors at compile time, ASP.NET MVC projects now include an MvcBuildViews property, which is disabled by default. To enable this property, open the project file and set the MvcBuildViews property to true, as shown in the following example:
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <MvcBuildViews>true</MvcBuildViews> </PropertyGroup>
Note Enabling this feature adds some overhead to the build time.
You can update projects that were created with previous releases of MVC to include build-time validation of views by performing the following steps:
- Open the project file in a text editor.
- Add the following element under the top-most
<PropertyGroup>
element:<MvcBuildViews>true</MvcBuildViews>
- At the end of the project file, uncomment the
<Target Name="AfterBuild">
element and modify it to match the following:
<Target Name="AfterBuild" Condition="'$(MvcBuildViews)'=='true'"> <AspNetCompiler VirtualPath="temp" PhysicalPath="$(ProjectDir)\..\$(ProjectName)" /> </Target>
- When install ”matplotlib” with ”pip”, if you get the following error, it means the “freetype” and “png” libraries needed by matplotlib are not installed:
- ZuulProxy fails with “RibbonCommand timed-out and no fallback available” when it should do failover
- does not contain bitcode. You must rebuild it with bitcode enabled
- This support library should not use a different version(x)than the compileSdkVersion(y)
- The function getUserId must be used with a prefix when a default namespace is not specified 解决办法
- This support library should not use a different version (24) than the compileSdkVersion (28)
- iOS--错误集锦--'...' does not contain bit code. You must rebuild it with bit code enabled ...
- android sdk location should not contain whitespace,as this can cause problem with the NDK tools
- The type List is not generic; it cannot be parameterized with arguments
- Xcode7 *** does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_
- does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), o
- fatal error C1853: '*.pch' is not a precompiled header file created with this compile
- The function equals must be used with a prefix when a default namespace is not specified
- Vmware Workstation 10.0.1 will not compile with kernel 3.13.2-200.fc
- does not contain bitcode. You must rebuild it with
- Command CompileSwift failed with a nonzero exit code when build iOS image classification
- does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE
- The type List is not generic; it cannot be parameterized with arguments<T>
- TextView with SingleLine as true and Gravity as Center not passing the events to the ViewPager if it has a Click Event
- the type List is not generic; it cannot be parameterized with arguments<T>解决办法