title: How to register typed httpClient service with autofac?
body: <p>I'm creating MVC web application which calls an api using .net core 2.2 using separate <code>HttpClient</code>s to call each controller (same api).</p>
  
  <p>Ex:</p>
  
  <ul>
  <li>For user controller actions : UserService (httpclient)</li>
  <li>For post controller actions : PostService (httpclient)</li>
  </ul>
  
  <p>In <strong><code>startup.cs</code></strong> I use DI as:</p>
  
  <pre><code>services.AddHttpClient&lt;IUserService, UserService&gt;();
  services.AddHttpClient&lt;IPostService, PostService&gt;();
  </code></pre>
  
  <p>In my handler :</p>
  
  <pre><code>public class CommandHandler : IRequestHandler&lt;Command, BaseResponse&gt;
  {
      private readonly IUserService _userService;
  
      public CommandHandler(IUserService userService)
      {
          _userService = userService;
      }
  
      public Task&lt;BaseResponse&gt; Handle(Command request, CancellationToken cancellationToken)
      {
          throw new System.NotImplementedException();
      }
  }
  </code></pre>
  
  <p>But when invoking command handler I get this error:</p>
  
  <blockquote>
    <p>None of the constructors found with
    'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type
    'xxx.Application.Services.Users.UserService' can be invoked with
    the available services and parameters: Cannot resolve parameter
    'System.Net.Http.HttpClient httpClient' of constructor 'Void
    .ctor(System.Net.Http.HttpClient,
    xxx.Application.Configurations.IApplicationConfigurations,
    Microsoft.Extensions.Logging.ILogger`1[xxx.Application.Services.Users.UserService])'.</p>
  </blockquote>
  
  <p>But I've registered services in autofac module:</p>
  
  <pre><code>public class ServiceModule : Module
  {
      protected override void Load(ContainerBuilder builder)
      {
          builder.RegisterAssemblyTypes(typeof(ServiceModule).Assembly)
                  .Where(t =&gt; t.Namespace.StartsWith("xxx.Application.Services"))
                  .AsImplementedInterfaces().InstancePerLifetimeScope();
      }
  }
  </code></pre>
  
  <p>Here is my <code>UserService</code> class constructor:</p>
  
  <pre><code>public UserService (HttpClient httpClient, IApplicationConfigurations applicationConfig, ILogger&lt;UserService&gt; logger)
  {
      _httpClient = httpClient;
      _applicationConfig = applicationConfig;
      _logger = logger;
  
      _remoteServiceBaseUrl = $"{_applicationConfig.WebApiBaseUrl}";
  }
  </code></pre>
  
  <p>I have two questions:</p>
  
  <ol>
  <li>What does the above error mean?</li>
  <li>Is it good practice to use separate httpclients for different controllers in api?</li>
  </ol>