Get error message if ModelState.IsValid fails?

前端 未结 11 1271
离开以前
离开以前 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:45

    I have no idea if this is your problem, but if you add a user and then change the name of your application, that user will remain in the database (of course), but will be invalid (which is correct behavior). However, there will be no error added for this type of failure. The error list is empty, but ModelState.IsValid will return false for the login.

提交回复
热议问题