billbogaiv / hybrid-model-binding

Provides the ability to bind models using both ModelBinder and ValueProvider in ASP.NET Core.
MIT License
104 stars 19 forks source link

Incompatible with a project that also uses WebApiCompatShim #28

Closed Place1 closed 4 years ago

Place1 commented 5 years ago

I've got a legacy project that originally used Web API and was ported to Dotnet core making use of microsoft's WebApiCompatShim.

I've got an API method that looks like this public List<MyModel> GetMyModel(int? size = null).

HybridModelBinding will throw an error on this line because it can't find a model of type Nullable<int>. The last resort to set the value of hydratedModel using Activator.CreateInstance also returns null.

Is there a way I can tell hybrid model binder to ignore WebApi controllers? I actually only need the library for MVC controllers.

billbogaiv commented 5 years ago

https://www.nuget.org/packages/HybridModelBinding/0.15.0 will correct the problem. The default convention did not have enough constraints to not bind against non-class types.

billbogaiv commented 4 years ago

This issue should be resolved.

closed!