title: ApplicationSignInManager class is null during authentication process
body: <p>The following code is being used in ASP.NET MVC 5 project. Everytime I run the following code the ApplicationSignInManager Class always comes to be null causing null reference exception. Being fairly a newbie I don't understand what code calls in the constructor of AccountController class passing in the instance of usermanager and sign in manager. perhaps that is where I need to focus but the truth is I can't find that part of the code. Anyone up for help?</p>
  
  <p>To be precise the exception is thrown from the HTTPost login method. The signInManager is always null.</p>
  
  <pre><code>var result = await SignInManager.PasswordSignInAsync(model.UserName, model.Password,
                                       model.RememberMe, shouldLockout: false);
  </code></pre>
  
  <p>Below is the c sharp code</p>
  
  <pre><code>[Authorize]
  public class AccountController : Controller
  {
      private ApplicationUserManager _userManager;
      private ApplicationSignInManager _signInManager;
  
      public AccountController()
      {
      }
  
      public AccountController(ApplicationUserManager userManager, ApplicationSignInManager signInManager)
      {
          UserManager = userManager;
          SignInManager = signInManager;
      }
  
      //
      // GET: /Account/Login
      [AllowAnonymous]
      public ActionResult Login(string returnUrl)
      {
          ViewBag.ReturnUrl = returnUrl;
          return View();
      }
  
  
      public ApplicationSignInManager SignInManager
      {
          get
          {
              return _signInManager ?? HttpContext.GetOwinContext().Get&lt;ApplicationSignInManager&gt;();
          }
          private set { _signInManager = value; }
      }
  
      //
      // POST: /Account/Login
      [HttpPost]
      [AllowAnonymous]
      [ValidateAntiForgeryToken]
      public async Task&lt;ActionResult&gt; Login(LoginViewModel model, string returnUrl)
      {
          if (!ModelState.IsValid)
          {
              return View(model);
          }
  
          // This doesn't count login failures towards account lockout
          // To enable password failures to trigger account lockout, change to shouldLockout: true
          var result = await SignInManager.PasswordSignInAsync(model.UserName, model.Password, model.RememberMe, shouldLockout: false);
          switch (result)
          {
              case SignInStatus.Success:
                  return RedirectToLocal(returnUrl);
              case SignInStatus.LockedOut:
                  return View("Lockout");
              case SignInStatus.RequiresVerification:
                  return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe });
              case SignInStatus.Failure:
              default:
                  ModelState.AddModelError("", "Invalid login attempt.");
                  return View(model);
          }
      }
   }
  </code></pre>
  
  <p>Code from IdentityConfig.</p>
  
  <pre><code>// Configure the application sign-in manager which is used in this application.
  public class ApplicationSignInManager : SignInManager&lt;ApplicationUser, string&gt;
  {
      public ApplicationSignInManager(ApplicationUserManager userManager, IAuthenticationManager authenticationManager)
          : base(userManager, authenticationManager)
      {
      }
  
      public override Task&lt;ClaimsIdentity&gt; CreateUserIdentityAsync(ApplicationUser user)
      {
          return user.GenerateUserIdentityAsync((ApplicationUserManager)UserManager);
      }
  
      public static ApplicationSignInManager Create(IdentityFactoryOptions&lt;ApplicationSignInManager&gt; options, IOwinContext context)
      {
          return new ApplicationSignInManager(context.GetUserManager&lt;ApplicationUserManager&gt;(), context.Authentication);
      }
  }
  </code></pre>