title: Why is my microsoft.owin.security.authenticationmanager Signin method not working?
body: <p>I working on an ASP MVC login form.</p>
  
  <p>I have pretty simple codes. A <code>Startup</code> class and an action trying to set the cookie. Below is my code :</p>
  
  <p><strong>Startup</strong> 
  which is located in App_Start (there is also a reference to it in <code>&lt;appSetting&gt;</code> with <code>key="owin:AppStartup"</code>)</p>
  
  <pre><code>public class Startup
  {
      public void Configuration(IAppBuilder app)
      {
          app.UseCookieAuthentication(new CookieAuthenticationOptions
          {
              AuthenticationType = "ApplicationCookie",
              LoginPath = new PathString("/auth/login"),
          });
      }
  }
  </code></pre>
  
  <p><strong>The action method that is suppose to authenticate the user is :</strong></p>
  
  <pre><code>[HttpPost]
  public ActionResult Login(user model)
  {
      if(ModelState.IsValid)
      {
          var identity = new ClaimsIdentity(new[]
          {
              new Claim(ClaimTypes.Email, "admin@admin.com"),
              new Claim(ClaimTypes.Name, "tom"),
              new Claim(ClaimTypes.Role, "admin")
          });
  
          var ctx = Request.GetOwinContext();
          var authManager = ctx.Authentication;
          authManager.SignIn(identity);
          return RedirectToAction("Index", "Home");
      }
      return View(model); 
  }
  </code></pre>
  
  <p>But this does not get the identity authenticated as <code>@User.Authenticated</code> is false in my <code>_Layout.cshtml</code> when <code>return RedirectToAction("Index", "Home");</code> and also the debbuger shows that <code>IsAuthenticated</code> property is false (in the controller <code>Login</code> action and in the <code>_Layout.cshtml</code>.</p>
  
  <p>I have checked that IIS is enabled for Anonymous authentication using my windows administrative tools and also I have checked that Startup is set when the application starts...</p>
  
  <p>I seems that <code>authManager.SignIn(identity)</code> is not doing its job.</p>
  
  <p>How can we solve this ?</p>
  
  <p><a href="https://i.stack.imgur.com/dgT6P.png" rel="nofollow noreferrer">debugger screenshot</a></p>
  
  <p>ps : I do not even see the browser popup asking if I want to save the password (I popped only once during my tests even though the user was still not authenticated)</p>