title: Custom model binder for a property
body: <p>I have the following controller action:</p>
  
  <pre><code>[HttpPost]
  public ViewResult DoSomething(MyModel model)
  {
      // do something
      return View();
  }
  </code></pre>
  
  <p>Where <code>MyModel</code> looks like this:</p>
  
  <pre><code>public class MyModel
  {
      public string PropertyA {get; set;}
      public IList&lt;int&gt; PropertyB {get; set;}
  }
  </code></pre>
  
  <p>So DefaultModelBinder should bind this without a problem. The only thing is that I want to use special/custom binder for binding <code>PropertyB</code> and I also want to reuse this binder. So I thought that solution would be to put a ModelBinder attribute before the PropertyB which of course doesn't work (ModelBinder attribute is not allowed on a properties). I see two solutions:</p>
  
  <ol>
  <li><p>To use action parameters on every single property instead of the whole model  (which I wouldn't prefer as the model has a lot of properties) like this:</p>
  
  <pre><code>public ViewResult DoSomething(string propertyA, [ModelBinder(typeof(MyModelBinder))] propertyB)
  </code></pre></li>
  <li><p>To create a new type lets say <code>MyCustomType: List&lt;int&gt;</code> and register model binder for this type (this is an option)</p></li>
  <li><p>Maybe to create a binder for MyModel, override <code>BindProperty</code> and if the property is <code>"PropertyB"</code> bind the property with my custom binder. Is this possible?</p></li>
  </ol>
  
  <p>Is there any other solution? </p>