Get error message if ModelState.IsValid fails?

前端 未结 11 1283
离开以前
离开以前 2020-11-30 02:27

I have this function in my controller.

[HttpPost]
public ActionResult Edit(EmployeesViewModel viewModel)
{
    Employee employee = GetEmployee(viewModel.Empl         


        
11条回答
  •  伪装坚强ぢ
    2020-11-30 02:33

    Ok Check and Add to Watch:

    1. Do a breakpoint at your ModelState line in your Code
    2. Add your model state to your Watch
    3. Expand ModelState "Values"
    4. Expand Values "Results View"

    Now you can see a list of all SubKey with its validation state at end of value.

    So search for the Invalid value.

提交回复
热议问题