Request.GetOwinContext().Authentication.SignIn not creating cookie

asp.net-identity, asp.net-web-api2, cookies, owin

Solution

Did you make sure you added the following to your App_Start/Startup.Auth.cs ?

public void ConfigureAuth(IAppBuilder app)
{
   app.UseCookieAuthentication(new CookieAuthenticationOptions
   {
      AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
      LoginPath = new PathString("/Account/Login")
   });
}

Check out Brock Allen's primer -

http://brockallen.com/2013/10/24/a-primer-on-owin-cookie-authentication-middleware-for-the-asp-net-developer/

Problem

The following Code is not creating .ASPNET Cookie, I am using this code in WebAPI custom login method ``` //TODO Validate Credential var claims = new List<Claim>(); claims.Add(new Claim(ClaimTypes.Name, "ABCDE")); claims.Add(new Claim(ClaimTypes.Email, "ABCDE@EFGH.com")); var id = new ClaimsIdentity(claims, DefaultAuthenticationTypes.ApplicationCookie); var authmgr = Request.GetOwinContext().Authentication; authmgr.SignIn(id); ```

Original source