Asp.net MVC模型绑定派生类

问题描述 投票:1回答:1

我已经写了一个抽象类PaymentMethod和2个派生类PaymentMethodInvoicePaymentMethodBilling。对于他们每个人,我都写了共享的EditorTemplates

GET运行正常,我选择了PaymentMethod并获得了正确的表格。如果我发布此表单,则模型绑定不起作用,它将尝试实例化抽象类PaymentMethod

我必须重写CreateModel protected override object CreateModel还是有更好的解决方案来处理此问题?

我已经编写了一个抽象类PaymentMethod和2个派生类,PaymentMethodInvoice和PaymentMethodBilling。我为每个人编写了共享的EditorTemplates。 GET工作正常,我选择...

c# asp.net asp.net-mvc model-binding defaultmodelbinder
1个回答
2
投票

我必须重写CreateModel

© www.soinside.com 2019 - 2024. All rights reserved.