【发布时间】:2014-10-09 08:14:29
【问题描述】:
整个错误信息:
The model item passed into the dictionary is of type
'MyClass`2[Implementation1,Implementation2]',
but this dictionary requires a model item of type
'MyClass`2[Interface1,Interface2]'.
在我看来,我有模型声明:
@model MyClass<Interface1, Interface2>
MyClass 是一个类,Interface1 和 Interface2 是接口
关于我正在调用的控制器操作:
return View(model);
在哪里: model 是类型...
MyClass<Implementation1,Implementation2>
...和 Implementation1 实现 Interface1 和 Implementation2 实现 Interface2
有什么办法可以避免这个错误,而不必像下面这样声明我的模型?
@model MyClass<Implementation1, Implementation2>
【问题讨论】:
-
有什么理由不能让你的模型使用
MyClass<Interface1, Interface2>?
标签: c# asp.net-mvc