title: Base Controller inheritance in ASP.NET Core identity
body: <p>I just started my first project in asp net core and I migrate from .Net framework.</p>
  
  <p>I created a new project using ASP.NET Core 2.1 and I added Identity via </p>
  
  <pre><code>Right click on project -&gt; Add -&gt; Add scaffolded items
  </code></pre>
  
  <p>to my project.</p>
  
  <p>First of all something make me confused. All of the files for identification moved to an area called Identity and Manage section files moved to Account folder. Most important thing is I don't have the account and manage controllers</p>
  
  <p>I created a new empty controller called <code>BaseController</code>:</p>
  
  <pre><code>public class BaseController : Controller
  {
      private ApplicationDbContext _db { get; set; }
  
      public BaseController(ApplicationDbContext db)
      {
          _db = db;
      }
  
      public override void OnActionExecuting(ActionExecutingContext filterContext)
      {
          if (HttpContext.User.Identity.IsAuthenticated)
          {
              string userEmail = User.Identity.Name;                
              ViewBag.CurrentUser = _db.Users.Where(u =&gt; u.Email.Equals(userEmail)).FirstOrDefault();
          }
  
          base.OnActionExecuting(filterContext);
      }
  }
  </code></pre>
  
  <p>In this controller I get the logged in user and pass it to a ViewBag and show it in my view.</p>
  
  <p>I have a <code>HomeController</code> that inherits from <code>BaseController</code>:</p>
  
  <pre><code>public class HomeController : BaseController
  {
      private UserManager&lt;ApplicationUser&gt; _userManager { get; set; }
      private readonly ApplicationDbContext _db;
  
      public HomeController(UserManager&lt;ApplicationUser&gt; userManager, 
                            ApplicationDbContext db) : base (db)
      {
          _userManager = userManager;
          _db = db;
      }
  
      public IActionResult Index()
      {
          return View();
      }
  
      [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
      public IActionResult Error()
      {
          return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
      }
  }
  </code></pre>
  
  <p>This part of code works fine but when I try to navigate to <code>Manage/Index</code> or <code>Manage/ChangePassword</code> I get this error and I don't know how can I resolve this problem. The cause of this error is ViewBag is empty because the base controller action never run.</p>
  
  <p>Sorry if my question is simple and is not professional</p>