【发布时间】:2014-03-14 23:02:12
【问题描述】:
我在控制器的 POST 操作上有一个自定义模型绑定器:
public ActionResult Detail(IProduct model)
Detail实际上是传递了一个FooProduct,它继承自Product: IProduct
在模型绑定器中我有 BindModel() 方法
bindingContext.ModelType 是IProduct。
当我检查 ControllerContext 或 BindingContext 时,我找不到任何可以让我知道 IProduct 的具体类型是 FooProduct 还是 BarProduct 的信息。
我怎样才能找到这个?
我可以解决这个问题,但我很好奇应该如何正确解决它。
【问题讨论】:
-
使用
bindingContext.Model.GetType()? -
@khillang .Model = null
标签: asp.net-mvc