razor syntax with errors compiles when it should not compile

谁说我不能喝 提交于 2019-11-28 23:12:51
Martin Buberl

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!