The problem is - my controller binds method name to the "Action" property of my model and of course it causes error in my model state because Method Name is String and my Action property is Object. I want the Action property to be null when it is not present in my Formdata.
Form data:
Model state on processing POST request:
My controller action:
[HttpPost]
public ActionResult RouteRoleActionsSave(TskRouteRoleAction model,List<TskAction.Actions> RoleActions = null)
{
using (var context = new SmartDbContext())
{
if (ModelState.IsValid)
{
return Json("ok");
}
return Json(ModelState);
}
}
My Model:
[Table("TSK_ROUTE_ROLE_ACTIONS")]
public class TskRouteRoleAction
{
[Key, Column("ROUTE_ID", Order = 0), ForeignKey("Route")]
public decimal RouteId { get; set; }
public TskRoute Route { get; set; }
[Key, Column("ROLE_ID", TypeName = "numeric", Order = 1), ForeignKey("Role")]
public TskRole.Roles? RoleId { get; set; }
public TskRole Role { get; set; }
[Key, Column("ACTION_ID", TypeName = "numeric", Order = 2), ForeignKey("Action")]
public TskAction.Actions? ActionId { get; set; }
public TskAction Action { get; set; }
}



