Razor Compiler Warning/Errors - ASP.NET MVC 4

ぃ、小莉子 提交于 2019-11-30 00:35:31

Arrrgghhh i had missed the following from the ROOT Web.config:

 <compilation debug="true" targetFramework="4.0">
  <!-- New -->
  <assemblies>
    <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
  </assemblies>
</compilation>

This allowed fixed the error and allowed me to use Intellisense within the View.

Putting back the following lines in root Web.config fixed:

<system.web>
    <pages>
      <namespaces>
        <add namespace="System.Web.Helpers" />
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Optimization" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Web.WebPages" />
      </namespaces>
    </pages>
</system.web>

I got it working by simply unloading and reloading the project. All the namespaces above were already there in the root web.config and I was still getting this issue.

Removing the temporary asp.net framework files works for me.

Stop IIS and remove everything under this folder:

C:\Windows\Microsoft.NET\Framework64\[framework version]\Temporary ASP.NET Files

Then restart IIS. Bam!

I tried by restart IIS, removed Temporary ASP.NET Files and changing the compilation tag in the web config file. None of them work for me.

I fixed the issue by removing and adding System.Web.MVC to the project.

In my case Razor syntax are Highlighted in red.

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