title: ASP.NET MVC3 User Login
body: <p>I have a User model with:</p>
  
  <pre><code>[Required]
  public string Password { get; set; }
  
  [Required]
  public string UserName { get; set; }
  </code></pre>
  
  <p>I have a <code>MyMembershipProvider : MembershipProvider</code> containing:</p>
  
  <pre><code>public override bool ValidateUser(string username, string password)
  {
     if (username == ConfigurationManager.AppSettings["DefaultUsername"] &amp;&amp; password == ConfigurationManager.AppSettings["DefaultUserPassword"])
     {
         return true;
     }
     else
     {
         return false;
     }
  }
  </code></pre>
  
  <p>My LogOn action looks like:</p>
  
  <pre><code>[HttpPost]
      public ActionResult LogOn(User model, string returnUrl)
      {
          if (ModelState.IsValid)
          {
              if (Membership.ValidateUser(model.UserName, model.Password))
              {
                  return RedirectToAction("Index", "Home");
              }
              else
              {
                  ModelState.AddModelError("", "The user name or password provided is incorrect.");
              }
          }
  
          // If we got this far, something failed, redisplay form
          return View(model);
      }
  </code></pre>
  
  <p>The Problem:</p>
  
  <p>When I specify the correct username and password, I can't seem to go to actions and controllers which contain the <code>[Authorize]</code> attribute. When I use breakpoint, it DOES fall in to <code>return RedirectToAction("Index", "Home");</code> but denies access to the Index page.</p>
  
  <p>Can anyone see where I am going horribly wrong?</p>