简体   繁体   中英

Razor pages in MVC are giving a compile error with System.Web.Helpers not being found

My razor view is failing to compile with the following error:

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?)

I have System.Web.Helpers added as a reference to my project, so I am not sure what else I need to do. I have also tried a clean rebuild after adding the reference, and no change.

What am I missing?

Aha figured it out. I needed to add

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

To the <assemblies> section of web.config!

Web.config line should go here:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM