Can abstract class be a parameter in a controller's action?

前端 未结 5 1725
既然无缘
既然无缘 2020-12-31 03:53

I have an Action function inside of a Controller, which is being called with AJAX. That Action is taking in 1 parameter. Client side, I construct a JSON object which shoul

5条回答
  •  抹茶落季
    2020-12-31 04:06

    The framework has no way of knowing which specific implementation you want, neither it will take the responsibility of such decision. So you have two possibilities here:

    1. Use a concrete type as action parameter
    2. Write a custom model binder for this abstract class which based on some request parameters will return a specific instance.

提交回复
热议问题