Why is Model Binding not working in my POST action method?

Your model contains fields, not properties (no getter/setter) so the model binder cannot set the values. Change your model to

public class LoginModel
{
   public string Username { get; set; }
   public string Password { get; set; }
}

Leave a Comment