title: User.Isauthenticated works randomly in ASP mvc
body: <p>I am trying to make sure that my users <code>log in</code> as a <code>elementryUser</code> .So in Login controller i check the <code>username</code> and <code>password</code> ,if the authentication be true the user can enter the page  the code to handle this is given below :(this part of code is login action )</p>
  
  <pre><code>FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
  System.Threading.Thread.Sleep(10000);
     if (User.IsInRole("ElementryUser"))
       {
          int UserId = objuserrepository.FindBy(i =&gt; i.Email == User.Identity.Name).First().Id;
          if (firstIdeaRepository.FindBy(i =&gt; i.UserId == UserId).Count() &gt; 0)
            {
              return RedirectToAction("Index", "FirstIdea");
            }
  
       }
     else
      {
        return RedirectToAction("Index", "Dashboard");
      }
  </code></pre>
  
  <p>As you can see if the <code>username</code> and <code>password</code> be true the cookie is initialized,in this line <code>if (User.IsInRole("ElementryUser"))</code> when i want to check my user permission but it doesn't work and it doesn't execute <code>if statement</code> .so i trace the code and i found that the <code>User.Isauthenticated</code> returns <code>false</code> !!!!why?what is the problem?So i put and thread between these two line because i thought maybe the thread could solve the problem.But it doens't work<code>User.Isauthenticated</code> returns <code>false</code> and sometimes returns <code>true</code> and when it returns true my <code>if statement</code> works .!!</p>
  
  <p>Best regards</p>