【问题标题】:Razor pages in MVC are giving a compile error with System.Web.Helpers not being foundMVC 中的 Razor 页面出现编译错误,找不到 System.Web.Helpers
【发布时间】:2010-11-12 22:26:11
【问题描述】:

我的 razor 视图无法编译并出现以下错误:

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS0234: The type or namespace name 'Helpers' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)

我添加了 System.Web.Helpers 作为对我的项目的引用,所以我不确定我还需要做什么。添加参考后,我还尝试了干净的重建,没有任何变化。

我错过了什么?

【问题讨论】:

标签: c# asp.net-mvc razor


【解决方案1】:

啊哈想通了。我需要添加

<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

到 web.config 的 &lt;assemblies&gt; 部分!

【讨论】:

  • 你能告诉我它是如何自动添加到网络配置文件中的吗?
  • 我在 web.config 中没有看到 assembly 部分。有示例文件吗?
  • 将该行放在
【解决方案2】:

Web.config 行应该放在这里:

  <configuration>
    <system.web>
      <compilation debug="true" targetFramework="4.0">
        <assemblies>
          <add assembly="System.Web.Helpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多