使用ajax发布数据时,ninject可以解决依赖关系吗?

时间:2014-11-09 19:09:05

标签: c# ajax asp.net-mvc ninject

我正在使用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
}

0 个答案:

没有答案