asp.net mvc - The type does not implement the IModelBinder interface. Parameter name: binderType -


i have implemented custom model binder webapi project

using webapi.controllers; using system.web.http.modelbinding; using system.web.http.controllers;  namespace webapi.models {     public class modelbasebinder : imodelbinder     {         public bool bindmodel(httpactioncontext actioncontext, modelbindingcontext bindingcontext)         {             if ((bindingcontext.model mymodel))             {                 //my code here                  controller.initmodel(model);                  return true;             }              return false;         }     } } 

but reason in global.asax.cs in line globalconfiguration.configure(webapiconfig.register);i getting error that: the type not implement imodelbinder interface. parameter name: bindertype.enter image description here

my global.asax.cs looking that:

arearegistration.registerallareas();             globalconfiguration.configure(webapiconfig.register); filterconfig.registerglobalfilters(globalfilters.filters); routeconfig.registerroutes(routetable.routes); bundleconfig.registerbundles(bundletable.bundles);  automapperconfiguration.configure(); globalconfiguration.configuration.bindparameter(typeof(modelbase), new modelbasebinder()); fluentvalidationmodelvalidatorprovider.configure(globalconfiguration.configuration); 

i guessing reason mvc looking system.web.modelbinding.imodelbinder in case of webapi have system.web.http.modelbinding.imodelbinder implementaton insteard.

do have idea how can fix that?

update:

i find out if comment method on controller:

public void post([frombody]mymodel model)         {             //my code here         } 

than not getting error above. still cant understand why getting such issue.

here models details

public class mymodel : modelbase     {     }  [modelbinder(typeof(modelbasebinder))] public class modelbase     {     } 

verify if modelbinderattribute on model 1 system.web.http.modelbinding or system.web.mvc.

there implementations of imodelbinder in both (system.web.http.modelbinding , system.web.mvc) , attribute match namespace binder


Comments

Popular posts from this blog

json - Zend error Connection -

javascript - Trigger mouseenter when an animated element touches mouse -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -