asp.net-mvc - 名称 'LabelFor' 在 MVC3 的当前上下文中不存在

标签 asp.net-mvc visual-studio-2010 razor visual-studio-2013

我将 Visual Studio 2010 MVC 项目升级到 Visual Studio 2013 .Net 4.5。

当我尝试向其中添加以下声明时,出现错误:

The type arguments for method 'System.Web.Mvc.Html.InputExtensions.PasswordFor(System.Web.Mvc.HtmlHelper, System.Linq.Expressions.Expression>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.



我检查了引用资料,它们都到位了。我在 View 文件夹中添加了一个 web.config,但这并没有解决它。

enter image description here

有什么我想念的吗?

最佳答案

升级到 MVC 5.1 后,我遇到了类似的问题,通过在 views\web.config 的配置部分将 System.Web.WebPages.Razor 的版本从 2.0.0.0 更新到 3.0.0.0 来解决

<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
  <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
  <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>

关于asp.net-mvc - 名称 'LabelFor' 在 MVC3 的当前上下文中不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19780636/

相关文章:

c# - 将模型数据从 View 传递到 Controller 并使用其值

visual-studio-2010 - Visual Studio 2010 可以帮助在 Visual Studio 中查看吗?

c# - 部分代码覆盖率 C# - Nunit

c# - @Html.Value of(x=>x.Property Name) 和@Model.Property Name 有什么区别

c# - 在mvc布局页面显示动态菜单

asp.net - 使用 oAuth 和 ASP.NET MVC + WebApi 进行身份验证

windows - 始终将 Windows 中的特定文件类型保存到一个位置?

asp.net-mvc-3 - Razor 注释语法

asp.net-mvc-4 - 模型绑定(bind)器 ValueProvider 附加到现有值 + MVC 4

javascript - 在客户端对页面配置进行排序的最佳方法