I am writing Angular.js/ASP.NET application. I have defined this model:
public class Dealer : EntityBase
{
...
public virtual List<DealerDefinedService> DealerDefinedServices { get; set; }
public virtual List<DealerDefinedServicesDiscount> DealerDefinedServicesDiscounts { get; set; }
...
}
And I have a controller that can receive that model:
[HttpPost]
public ActionResult Edit(Dealer model)
{
if (ModelState.IsValid)
{
dealerService.EditDealer(model);
return RedirectToAction("Index");
}
return View("Create", model);
}
In my Angular.js controller I am trying to send this object:
{
"DealerDefinedServices": [
{
...
}
],
"DealerDefinedServicesDiscounts": [
{
...
}
]
}
If both "DealerDefinedServices" and "DealerDefinedServicesDiscounts" parameters are set, ASP.NET controller receives only one of them, but other becomes null. I was trying to fix this problem for hours and finally fixed it by renaming one of mentioned parameters because I thought that maybe the problem is that parameters have similar names. So, what's the problem, why controller can't see one of parameters if they have simillar names?