title: Injecting Services into a Base Controller class
body: <h2>Scenario:</h2>
  
  <p>An MVC3 app that uses constructor injection to provide services for a given controller:</p>
  
  <pre><code>public class HomeController : BaseController
  {
      private readonly IArticleService _articleService;
  
      public HomeController(IArticleService articleService)
      {
          _articleService = articleService;
      }
  
      public ActionResult Index()
      {
          // do stuff with services
          return View()
      }
  }
  </code></pre>
  
  <h2>Intention:</h2>
  
  <p>I have a <code>UserService</code> that fetches user principal data from Active Directory that I want usable from all my Controllers, from the base controller. </p>
  
  <p>I have tried to inject this service into my <code>BaseController</code> like this:</p>
  
  <pre><code>public class BaseController : Controller
  {
      private readonly IUserService _userService;
  
      public BaseController(IUserService userService)
      {
          _userService = userService;
      }
  }
  </code></pre>
  
  <p>All by itself it looks fine, but now the constructor in my <code>HomeController</code> is off, as it needs a <code>: base()</code> initializer. The trouble is, the base initializer is not parameterless due the <code>UserService</code> injection.</p>
  
  <pre><code>public HomeController(IArticleService articleService) : base(IUserService userService)
  </code></pre>
  
  <p>The code above results in syntax errors.</p>
  
  <h2>Question(s):</h2>
  
  <p>How do I properly inject a service into my <code>BaseController</code> and initialize it from the child Controller classes (ex. HomeController)?</p>