title: What is the right way to instantiate a controller in ASP.NET Core without using a DI container?
body: <p>In <code>Startup.ConfigureServices</code>, I have this piece of code:</p>
  
  <pre><code>services.AddSingleton&lt;IControllerActivator&gt;(new LicenseKeyControllerActivator(keyService));
  </code></pre>
  
  <p>LicenseKeyControllerActivator looks like this:</p>
  
  <pre><code>public class LicenseKeyControllerActivator
      : IControllerActivator
  {
      private readonly ILicenseKeyService _keyService;
  
      public LicenseKeyControllerActivator(ILicenseKeyService licenseKeyService)
      {
          _keyService = licenseKeyService;
      }
  
      public object Create(ControllerContext context)
      {
          return new LicenseController(_keyService);
      }
  
      public void Release(ControllerContext context, object controller)
      {
          return;
      }
  }
  </code></pre>
  
  <p>During the request-response lifecycle, the activator creates the controller, the <code>DataAnnotations</code>-based validations work, the filters filter, but no controller method is ever called. In fact, after the <code>set</code> is called on the DTO, <code>Release</code> is called immediately.</p>
  
  <p>I'm not sure if this is <a href="https://stackoverflow.com/questions/43461959/attribute-routing-to-controller-action-isnt-working-in-asp-net-core">a routing problem</a>, or a controller activator issue.</p>