[HttpPost]
public ActionResult Create(ALLOCATION_M allocationM)
{
try
{
if (ModelState.IsValid)
{
allocationM.ALLO_ID = GetId();
_unitOfWork.AllocationMRepository.Insert(allocationM);
_unitOfWork.Save();
return RedirectToAction("Index");
}
}
catch (DataException)
{
ModelState.AddModelError("", EditorLocalization.AllocationMasterController_Create_Unable_to_save_changes__Try_again__and_if_the_problem_persists__see_your_system_administrator_);
}
return View(allocationM);
}
C# 运行时内部如何检查ModelState.IsValid
?我的意思是当从视图调用 post 方法时,它如何检查我的模型状态是有效还是无效。