我将 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,但这并没有解决它。
有什么我想念的吗?
最佳答案
升级到 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/