2
我對我的項目使用ASP.NET MVC 2。ASP.NET MVC 2.無法創建接口的實例
我嘗試使用下面的代碼編輯我的產品信息:
[HttpGet]
public ActionResult Edit(int id)
{
IProduct product = productService.getProductById(id);
return View(product);
}
IProduct等IEntities使用IoC的溫莎城堡instansing。編輯頁面成功加載。在我的頁面頂部,我聲明該頁面必須Inherits =「System.Web.Mvc.ViewPage 〈 DomainModel.Entities.IProduct 〉。但是,當我嘗試使用下一個代碼更新我的更改時:
[HttpPost]
public ActionResult Edit(IProduct product)
{
//Whatever i did here i always get the error prevents my any actions
}
然後我收到錯誤'無法創建接口的實例。'
任何人都可以解釋,爲什麼? 對不起,可能英文不好,並感謝所有的答案。
您是否有這種情況的自定義模型聯編程序的示例? – camainc 2011-09-09 16:54:51