Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public partial class Startup
- {
- // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
- public void ConfigureAuth(IAppBuilder app)
- {
- // Configure the db context and user manager to use a single instance per request
- app.CreatePerOwinContext(ApplicationDbContext.Create);
- app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
- // Other things...
- }
- }
- public class AccountController : Controller
- {
- private ApplicationUserManager _userManager;
- public AccountController() { }
- public AccountController(ApplicationUserManager userManager)
- {
- UserManager = userManager;
- }
- public ApplicationUserManager UserManager {
- get
- {
- // HttpContext.GetOwinContext().Get<ApplicationDbContext>(); // The ApplicationDbContextis retrieved like so
- return _userManager ?? HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>();
- }
- private set
- {
- _userManager = value;
- }
- }
- // Other things...
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement