Razor编译器警告/错误 - ASP.NET MVC 4 [英] Razor Compiler Warning/Errors - ASP.NET MVC 4

查看:482
本文介绍了Razor编译器警告/错误 - ASP.NET MVC 4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到一个似乎已在此处报告的问题:





我认为这个问题也许在视图中也得到以下编译器错误:


当前上下文中不存在Html名称




我做错了什么?

解决方案

Arrrgghhh我错过了以下从ROOT Web.config:

 编译debug =truetargetFramework =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>

这允许修正错误并允许我在视图中使用Intellisense。


I have an issue which seems to have been reported here:

Need razor view engine auto-complete to work in a class library?

My issue is the following Warning:

G:\Accountable\Accountable\Views\LedgerUser\EditorTemplates\LedgerServiceViewModel.cshtml: ASP.NET runtime error: There is no build provider registered for the extension '.cshtml'. You can register one in the section in machine.config or web.config. Make sure is has a BuildProviderAppliesToAttribute attribute which includes the value 'Web' or 'All'.

This issue is apparent in all my views. Sample images below.

Now all posts and references online that I have found are referencing to adding various Web.config (as mentioned in the previous post) options, but this doesn't seem to work, as I have these configurations defaulted in the project. Here are my Web Configs:

Main Web.config

View root Web Config

I think this issue maybe while im also getting the following compiler errors on the Views:

The name 'Html' does not exist in the current context

What am I doing wrong?

解决方案

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.

这篇关于Razor编译器警告/错误 - ASP.NET MVC 4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆