title: C# ASP.NET Core Cannot bind to a model of type 'Microsoft.AspNetCore.Http.FormCollection'
body: <p>I am getting the following error <code>An unhandled exception occurred while processing the request. InvalidOperationException: The 'Microsoft.AspNetCore.Mvc.ModelBinding.Binders.FormCollectionModelBinder' cannot bind to a model of type 'Microsoft.AspNetCore.Http.FormCollection'. Change the model type to 'Microsoft.AspNetCore.Http.IFormCollection' instead.</code></p>
  
  <p>This is when I use the following code:</p>
  
  <pre><code>[ValidateAntiForgeryToken]
  [HttpPost]
  public IActionResult Index(Test test, FormCollection formCollection)
  {        
      var feesAmountArray = new List&lt;string&gt;();
  
      foreach (var item in formCollection.Keys.Where(k =&gt; k.StartsWith("FeesAmount-")))
      {
          feesAmountArray.Add(formCollection[item].ToString().TrimEnd(','));
      }
  
      var feesAmount = string.Join(",", feesAmountArray);
  
      if (ModelState.IsValid)
      {
      }
  
      return View(test);
  }
  </code></pre>
  
  <p>Within the model <code>Test</code> I am using a <code>[Decimal]</code> attribute which is used in conjunction with a <code>ModelBinder</code>, but I am not wanting to bind to the form in anyway, I just want to bind to the model, so I am a little confused as to why this message is presenting itself.</p>
  
  <p>The code relating to the ModelBinder can be found at:</p>
  
  <p><a href="https://stackoverflow.com/questions/46056221/c-sharp-asp-net-core-modelbinder-not-updating-model">C# ASP.NET Core ModelBinder not Updating Model</a></p>
  
  <p>Any help would be much appreciated :-)</p>