razor syntax with errors compiles when it should not compile

前端 未结 1 2071
鱼传尺愫
鱼传尺愫 2020-12-15 06:22

So I an into an error at runtime with my asp.net mvc3 app, when I checked the code I see that it has a red line on it, the error list says there is no s

相关标签:
1条回答
  • 2020-12-15 06:49

    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

    0 讨论(0)
提交回复
热议问题