var userManager = HttpContext.GetOwinContext().GetUserManager(); var signInManager = HttpContext.GetOwinContext().Get (); var user = await userManager.FindAsync(username, password); if(user != null){ await signInManager.SignInAsync(user, false, false); }
var signInManager = HttpContext.GetOwinContext().GetIn both examples, we get the instance of the ApplicationSignInManager from the Owin context and use its SignInAsync or ExternalSignInAsync method to sign in the user. The package library involved is Microsoft.AspNet.Identity.Owin.(); var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync(); if(loginInfo != null){ var result = await signInManager.ExternalSignInAsync(loginInfo, isPersistent: false); if(result == SignInStatus.Success){ //redirect to home page or any other protected page } }