I am developing an application using Angular.js and ASP.NET. Here is the model I have defined:
public class Dealer : EntityBase
{
...
public virtual List<DealerDefinedService> DealerDefinedServices { get; set; }
public virtual List<DealerDefinedServicesDiscount> DealerDefinedServicesDiscounts { get; set; }
...
}
I also have a controller that can handle this model:
[HttpPost]
public ActionResult Edit(Dealer model)
{
if (ModelState.IsValid)
{
dealerService.EditDealer(model);
return RedirectToAction("Index");
}
return View("Create", model);
}
When trying to send an object from my Angular.js controller with these properties:
{
"DealerDefinedServices": [
{
...
}
],
"DealerDefinedServicesDiscounts": [
{
...
}
]
}
The issue arises when both "DealerDefinedServices" and "DealerDefinedServicesDiscounts" parameters are set—only one of them gets recognized by the ASP.NET controller while the other becomes null. After hours of troubleshooting, I was able to fix it by renaming one of the parameters as I suspected the problem might be due to their similar names. What could be causing the controller to overlook one parameter when they share similar names?