Skip to content

Instantly share code, notes, and snippets.

@xivSolutions
Created April 13, 2014 15:17
Show Gist options
  • Save xivSolutions/10588256 to your computer and use it in GitHub Desktop.
Save xivSolutions/10588256 to your computer and use it in GitHub Desktop.
To Inject or Not To Inject UserManager?
// The Identity 2.0 example project has a Constructor Override:
public AccountController()
{
}
// When would we do THIS?
public AccountController(ApplicationUserManager userManager)
{
UserManager = userManager;
}
// When THIS exists?
private ApplicationUserManager _userManager;
public ApplicationUserManager UserManager
{
get
{
return _userManager ?? HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>();
}
private set
{
_userManager = value;
}
}
// Is there strong reason for or against injecting the UserManager?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment