You need to tell us the description of the issue you are facing. You need to help us to help you out. Following is the reason I could figure out just by reading the code.
The code you gave will throw this error because the default constructor never initializes
UserManager object. Also, it is possible that someone can assign null to your parameterized constructor.
I would suggest you to
either initialize your UserManager in default constructor as:
public AccountController()
{
UserManager = new UserManager<applicationuser>();
}
Or add a null check:
if(UserManager !=null)
{
var result = await UserManager.CreateAsync(user, model.Password);
if (result.Succeeded)
{
var userId = user.Id;
var userName = user.UserName;
userProfileService.CreateUserProfile(userId);
return RedirectToAction("Index", "Account");
}
else
{
AddErrors(result);
}
}
Take the approach which suits your design.