小编int*_*t32的帖子

ASP.NET MVC 2.无法创建接口的实例

我将ASP.NET MVC 2用于我的项目.

我正在尝试使用下一代码编辑我的产品信息:

    [HttpGet]
    public ActionResult Edit(int id)
    {
        IProduct product = productService.getProductById(id);
        return View(product);
    }
Run Code Online (Sandbox Code Playgroud)

IP产品和其他IEntities使用IoC Castle Windsor进行实例化.已成功加载编辑页面.在我的页面顶部,我声明该页面必须是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
    }
Run Code Online (Sandbox Code Playgroud)

然后我收到错误'无法创建接口的实例'.

谁能澄清为什么?对不起,可能是英语不好,谢谢你的回答.

interface asp.net-mvc-2

2
推荐指数
1
解决办法
2022
查看次数

标签 统计

asp.net-mvc-2 ×1

interface ×1