title: ModelState.IsValid alway return false when i try to log in
body: <p>I'm trying to login on my website but i have some problems when i do it</p>
  
  <p>This is the login code from controller:</p>
  
  <pre><code>public ActionResult Login()
  {
      return View();
  }
  
  [HttpPost]
  [ValidateAntiForgeryToken]
  public ActionResult LogIn(Accounts U)
  {
      if (ModelState.IsValid)
      {
          if (IsValid(U.Username, U.Password))
          {
              FormsAuthentication.SetAuthCookie(U.Username, false);
              return RedirectToAction("Index", "Home");
          }
          else
          {
              ModelState.AddModelError("", "Invalid Username or Password");
          }
      }
      else
      {
           var errors = ModelState
              .Where(x =&gt; x.Value.Errors.Count &gt; 0)
              .Select(x =&gt; new { x.Key, x.Value.Errors })
              .ToArray();
           ModelState.AddModelError("", errors.ToString());
      }
  
      return View(U);
  }
  </code></pre>
  
  <p>And this is the error i get: </p>
  
  <blockquote>
    <p>&lt;>f__AnonymousType1`2[System.String,System.Web.Mvc.ModelErrorCollection][]</p>
  </blockquote>
  
  <p>I also modify the view with one took from internet but still the same result.</p>
  
  <p>PS: Register is working without any problems</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I changed this :</p>
  
  <pre><code>var errors = ModelState
                  .Where(x =&gt; x.Value.Errors.Count &gt; 0)
                  .Select(x =&gt; new { x.Key, x.Value.Errors })
                  .ToArray();
  </code></pre>
  
  <p>into this:</p>
  
  <pre><code>var errors = ModelState.Values.SelectMany(v =&gt; v.Errors);
  </code></pre>
  
  <p>and this is the error:</p>
  
  <blockquote>
    <p>System.Linq.Enumerable+d__16`2[System.Web.Mvc.ModelState,System.Web.Mvc.ModelError]</p>
  </blockquote>
  
  <p>Account model:</p>
  
  <pre><code>public partial class Accounts
  {
      public string Id { get; set; }
  
      [Required]
      public string Username { get; set; }
  
      [Required]
      [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
      [DataType(DataType.Password)]
      [Display(Name = "Password")]
      public string Password { get; set; }
  
      [DataType(DataType.Password)]
      [Display(Name = "Confirm password")]
      [NotMapped]
      public string ConfirmPassword { get; set; }
  
      [Required]
      [EmailAddress]
      public string Email { get; set; }
  
      public string FirstName { get; set; }
  
      public string LastName { get; set; }
  
      public string PhoneNumber { get; set; }
  }
  </code></pre>