title: ApplicationUserManager - UserManager throwing exception on creating new user
body: <p>I am using the default ASP.net 'Register' method to create a new user from another controller:</p>
  
  <pre><code>    public async Task&lt;ActionResult&gt; SyncNewUsers()
      {
              RegisterViewModel register = new RegisterViewModel();
              register.UserName = item.entity_name;
              register.Email = item.fields.preferred_email;
              register.MobilePhone = item.fields.preferred_phone;
              register.Password = "IT@test123";
              register.ConfirmPassword = "IT@test123";
              register.Role = "Admin";
                  await new AccountController().RegisterNewUser(register);
  
              return View();
      }
  </code></pre>
  
  <p>My 'Register' method:</p>
  
  <pre><code>        public async Task&lt;ActionResult&gt; RegisterNewUser(RegisterViewModel model)
      {
          if (ModelState.IsValid)
          {
              var user = new ApplicationUser { UserName = model.UserName, Email = model.Email, PhoneNumber = model.MobilePhone };
  
              var result = await UserManager.CreateAsync(user, model.Password);
              if (result.Succeeded)
              {
                  await this.UserManager.AddToRoleAsync(user.Id, model.Role);
  
                  await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
                  AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
  
  
  
                  return RedirectToAction("newxpusers", "Users");
              }
              AddErrors(result);
          }
  
          return View(model);
      }
  </code></pre>
  
  <p>However, it never gets further than <code>var result = await UserManager.CreateAsync(user, model.Password);</code> where I get the error: <em>'UserManager' threw an exception of type 'system.nullreferenceexception'</em></p>
  
  <p>I would assume it's got something to do with the HttpContext in the UserManager, but I am unsure how to deal with this when I am passing the Model to this method on the fly, rather than through a standard form submission.</p>