I'm new in knockout. I want to use it in my project on ASP.NET MVC. But I don't understand how to show validation errors from server.
For example we have a authentication form with login and password inputs. Required or length validation I can make on client side. But what shall I do when I submit form to server but the user with submited login not found or password incorrect? How can I show server validation error with knockout.js?
Update 1
Controller code for example, it will return dictionary: item key, error message
[HttpPost]
public ActionResult MyAction(MyModel model)
{
if(ModelState.IsValid)
{
...
}
var errorList = ModelState.ToDictionary(
kvp => kvp.Key,
kvp => kvp.Value.Errors.Select(e => e.ErrorMessage).ToArray());
return Json(errorList);
}