Previous versions of ASP.Net exposed the inheritable class System.Web.Mvc.DefaultModelBinder
, which allowed the method CreateModel
in order to return the type of model which the incoming request should bind to. It's very handy for having a single method for different base classes.
This doesn't exist in version 5. You can create Binders easily by inheriting from IModelBinder
- in BindModelAsync
the Model type can't be set. You can set the ModelMetadata.Model (which I believe would be an instantiation of the target type), but it's unclear how to set the Metadata itself which I think is needed.
Essentially I'm trying to ask this question for the newer framework.