Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2014
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. public partial class Startup
  2. {
  3. // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
  4. public void ConfigureAuth(IAppBuilder app)
  5. {
  6. // Configure the db context and user manager to use a single instance per request
  7. app.CreatePerOwinContext(ApplicationDbContext.Create);
  8. app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
  9.  
  10. // Other things...
  11. }
  12. }
  13.  
  14. public class AccountController : Controller
  15. {
  16. private ApplicationUserManager _userManager;
  17.  
  18. public AccountController() { }
  19.  
  20. public AccountController(ApplicationUserManager userManager)
  21. {
  22. UserManager = userManager;
  23. }
  24.  
  25. public ApplicationUserManager UserManager {
  26. get
  27. {
  28. // HttpContext.GetOwinContext().Get<ApplicationDbContext>(); // The ApplicationDbContextis retrieved like so
  29. return _userManager ?? HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>();
  30. }
  31. private set
  32. {
  33. _userManager = value;
  34. }
  35. }
  36.  
  37. // Other things...
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement