title: UserManager always null in ASPNET Identity 2 app
body: <h2>Setup:</h2>
  
  <p>I have an MVC 5 app with a number of library projects, created using my own exported templates. The exported templates have been working fine.</p>
  
  <p>I am using ASPNET Identity.  I am just using a copy of the Microsoft Aspnet Identity Sample as supplied in the relevant NuGet package, that I have woven into my exported templates.  This has been working fine.</p>
  
  <p>I have not touched the files supplied in the ASPNET Identity 2 sample.</p>
  
  <p>The error happens  in the IdentityConfig.cs file.</p>
  
  <p>For some reason, it started coming up with an error stating that it could not load the file for System.Web.Mvc, as it could not find version 5.1.0.0. </p>
  
  <p>As a result, I used NuGet to update the Microsoft.Aspnet.Mvc package. This installed version 5.2.2.0 of system.web.mvc, and this effectively cleared that error.</p>
  
  <p>However...</p>
  
  <p>Although the application loads, whenever I try to login or create a new user, a new error comes up (shown below), essentially stating that the ASPNET Identity UserManager object was null.</p>
  
  <p>I updated the microsoft.aspnet.identity package, but the error still happens when trying to login or create a new user (the login page displays ok, but the error happens when you click the log in button)</p>
  
  <p>Before getting the error regarding the system.web.mvc reference, I could log in and register users at my leisure.</p>
  
  <h2>Error:</h2>
  
  <p>This is the error shown when I try to login.  When I try to register a new user, I get a different error, but with the same cause: the UserManager object is null, when it shouldn't be.</p>
  
  <pre><code>Object reference not set to an instance of an object.
  
  Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
  
  Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
  
  Source Error: 
  
  
  Line 324:        public async Task&lt;SignInStatus&gt; PasswordSignIn(string userName, string password, bool isPersistent, bool shouldLockout)
  Line 325:        {
  Line 326:            var user = await UserManager.FindByNameAsync(userName);
  Line 327:            if (user == null)
  Line 328:            {
  
  Source File: c:\Users\[user name]\Documents\Visual Studio 2013\Projects\[My solution]\Models\IdentityConfig.cs    Line: 326 
  </code></pre>
  
  <h2>Question:</h2>
  
  <ol>
  <li><p>Does anyone know what could be causing this?  </p></li>
  <li><p>Could, for example, it be possible that the Microsoft Aspnet Identity sample code needs updating for version 5.2.2.0 of the system.web.mvc dll?</p></li>
  </ol>
  
  <p>NOTE: I'm afraid I can't determine or recall what I changed just before the errors started happening. I haven't been working on this project for a while.</p>