title: ASP.NET Core - How to reuse methods created in one controller in another controller?
body: <p>One way is to create use class inheritance, but is there any other way  I could reuse methods that I created in one controller in another controller?  </p>
  
  <p>EDIT: should I use a custom basecontroller like this?</p>
  
  <hr>
  
  <pre><code>public class BaseController : Controller
  {
      private readonly ApplicationDbContext _context;
      private readonly IIdentityService _identityService;
  
      public BaseController(ApplicationDbContext context, IIdentityService identityService)
      {
          _context = context;
          _identityService = identityService;
      } 
  
      public BaseController()
      {
      }
  
       //reusable methods
       public async Task&lt;Account&gt; GetAccount()
       {
          //code to do something, i.e query database
       }
  
  
  }
  </code></pre>
  
  <hr>
  
  <pre><code>public class MyController : BaseController
  {
      private readonly ApplicationDbContext _context;
      private readonly IIdentityService _identityService;
  
      public MyController(ApplicationDbContext context, IIdentityService identityService)
      {
          _context = context;
          _identityService = identityService;
      } 
  
      public async Task&lt;IActionResult&gt; DoSomething()
      {
  
        var account = await GetAccount(); 
  
        //do something
  
        Return Ok();
      }
  }
  </code></pre>