0

We are using custom model binders, how to disable model binding for one action method, so that i can directly post data from angular http post request, I have taken different/new class as parameter for action method. but due to custom model binders loosing posted data.

Gopinath
  • 3
  • 2

1 Answers1

0

I don't think you can disable custom model binding for an action, but you can do it by (model) class type.

I'm guessing you've got something like this:

ModelBinders.Binders.DefaultBinder = new CustomModelBinderClass();

The Binders Property is a dictionary mapping (model) types to model binder classes, so if you can use a unique model type in this one scenario, you should be able to change back to the default binder for that model type like this:

var defaultBinder = new DefaultModelBinder();
ModelBinders.Binders.Add(typeof(ModelThatNeedsDefaultBinding), defaultBinder);
jefftrotman
  • 1,059
  • 7
  • 16