在我的.cshtml文件中,无论我在哪里使用 @html.textboxfor
我会遇到错误这是一个示例代码:
@model WebComposite.Models.CompositeModel
<label for="name">Name</label>
@Html.TextBoxFor(m => m.name)
错误:
Error #1:
'System.Web.Mvc.Html.InputExtensions.TextBoxFor<TModel,TProperty>(System.Web.Mvc.HtmlHelper<TModel>, System.Linq.Expressions.Expression<System.Func<TModel,TProperty>>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
Error #2:
One or more types required to compile a dynamic expression cannot be found. Are you missing a reference?
有什么想法?
如果其他任何人都在想,这就是我解决的方法:
1. right click on the project -> select properties
2. select Application
3. change "target framework" (I was at 4.5, so I changed it to 4)
4. change "target framework" to whatever it was before step 3
web.config已清理,添加了适当的参考,做一个构建,一切都应该返回正常