title: How to pass parameter into autofac using RegisterType and Controller factory
body: <p>I have this class:</p>
  
  <pre><code>public class MessageService
  {
      private readonly IMessageSender messageSender;
  
      public MessageService(IMessageSender messageSender)
      {
          this.messageSender = messageSender;
      }
  }
  </code></pre>
  
  <p>How to register autofac to pass parameter inside constructor:</p>
  
  <pre><code>var builder = new ContainerBuilder();
  builder.RegisterControllers(typeof(MvcApplication).Assembly);
  var container = builder.Build();
  DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
  builder.RegisterType&lt;MandrillMessageSender&gt;().As&lt;IMessageSender&gt;();
  
  builder.RegisterType&lt;MessageService&gt;(new MandrillMessageSender()); // NOTE THIS STRING IS NOT WORKING
  </code></pre>
  
  <p>So the result should work like this, when I pass parameter inside controller constructor messageService object should be created with inserted MandrillMessageSerder.</p>
  
  <pre><code>public Home(MessageService messageService)
  </code></pre>