我正在使用System.Web.Mvc.Ajax
进行表单发布。它试图发布的模型包含ISomeInterface
类型的属性。发布表单数据时,我收到异常MissingMethodException: Cannot create an instance of an interface. Object type 'Model.Abstract.ISomeInterface'.
所有相关的ninject绑定都已正确完成。如果我将属性类型更改为其具体实现,则模型将成功绑定。我在这里做错了吗?
这是表格
@using (Ajax.BeginForm("_AddNote", new AjaxOptions { HttpMethod = "Post" }))
{
@Html.TextBoxFor(model => model.Note.NoteBody)
<input type="submit" value="Post"/>
}
这是发布表单的地方
[HttpPost]
public ActionResult _AddNote(StudentViewModel postedData)
{
//add note stuff;
}
这是模型模型试图绑定到
public class StudentViewModel
{
public INote Note { get; set;}
//Other Properties
}