title: ASP.NET Identity check user roles is not working
body: <p>I have an ASP.NET MVC 5 application. I'm using the standard ASP.NET Identity provider for user and role management. It is important that I'm using the IdentityUser from an own repository project, but this seems ok. I can register, login, edit users, and manage their roles.</p>
  
  <p>I add user to Role with these lines:</p>
  
  <pre><code>UserManager.AddToRole(userdetail.Id, r);
  db.Entry(userdetail).State = EntityState.Modified;
  db.SaveChanges();
  </code></pre>
  
  <p>This seems working in DB level.</p>
  
  <p>But, I can't use Role based authentications, actually the simples</p>
  
  <pre><code>HttpContext.User.IsInRole("Administrator")
  </code></pre>
  
  <p>doesn't working too.</p>
  
  <pre><code>[Authorize(Roles="Administrator")]
  </code></pre>
  
  <p>doesn't working too.</p>
  
  <p>I can check only with this method, whether user is an administrator:</p>
  
  <pre><code>UserManager.IsInRole(userID, "Administrator").
  </code></pre>
  
  <p>Why?</p>
  
  <p>In every tutorial what I found, everything works fine. The different project repository could be the reason? Or ASP.NET Identity is broken so much?</p>
  
  <p>Please advice,</p>