MTplus
MTplus

Reputation: 2391

how to get instance of usermanager in asp.net identity in custom controller

How can I in my custom controller get an instance of ApplicationUserManager so that I can find a user by its id and then be able to update the user?

Upvotes: 0

Views: 829

Answers (1)

Sam FarajpourGhamari
Sam FarajpourGhamari

Reputation: 14741

Simply call:

var userManager = HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>();

inside any action you want to access the user manager. you also need to add following namespace also:

using Microsoft.AspNet.Identity.Owin;

Upvotes: 1

Related Questions