title: Asp.net MVC with SimpleMembershipProvider
body: <p>I'm developing a web site using ASP.NET MVC.
  For membership, I'm using SimpleMembershipProvider. So, here is a part of my web.config:
          
      
      
      
      
        
      
      
        
          
          
        
      
      
      
      </p>
  
  <p>This is on my Global.asax, in the Application_Start:</p>
  
  <pre><code>WebSecurity.InitializeDatabaseConnection("DefaultConnection", "Users", "UserID", "UserName", autoCreateTables: true);
  </code></pre>
  
  <p>Well, my problem is in the LogIn.
  Apparently, when I use WebSecurity.Login(username, password) it works. I assumed that because when putting it in an IF statement, returns true.
  But, when I use WebSecurity.IsAuthenticated.. it ALWAYS return FALSE.
  This is my LogIn controller:</p>
  
  <pre><code>public ActionResult ToLogIn([Bind(Include = "UserName, Password")] LogInModel _user)
      {
          if (ModelState.IsValid)
          {
              if (WebSecurity.Login(_user.UserName, _user.Password))
              {
                  return RedirectToAction("Index", "Home")
              }
  
          }
          return View(_user);
      }
  </code></pre>
  
  <p>It works and redirect to the Index Home page, which use a layout where I check the WebSecurity.IsAuthenticated and, as I say before, it always return False.</p>