title: Autofac + MVC3 + Html.Action
body: <p>I've got the same problem as in <a href="https://stackoverflow.com/questions/6281579/autofac-handle-multiple-requests-in-asp-net-mvc-3">this question</a></p>
  
  <p>The error message is:
  <em>A single instance of controller 'Search.Web.Controllers.AdvancedController' cannot be used to handle multiple requests. If a custom controller factory is in use, make sure that it creates a new instance of the controller for each request.</em></p>
  
  <p>Code in Global.asax:</p>
  
  <pre><code>protected void Application_Start()
  {
    var containerBuilder = new ContainerBuilder();
  
    containerBuilder.RegisterType&lt;AdvancedController&gt;().InstancePerHttpRequest();
    containerBuilder.RegisterType&lt;MemoryBodyTypeRepository&gt;().As&lt;IBodyTypeRepository&gt;;
    containerBuilder.RegisterType&lt;BodyTypePictureClassFinder&gt;().As&lt;IBodyTypePictureClassFinder&gt;();
  
    var container = containerBuilder.Build();
  
    DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
    AreaRegistration.RegisterAllAreas();
  
    RegisterGlobalFilters(GlobalFilters.Filters);
    RegisterRoutes(RouteTable.Routes);
  }
  </code></pre>
  
  <p>This is some Code from AdvancedController:</p>
  
  <pre><code>private readonly IBodyTypeRepository _bodyTypeRepository;
  private readonly IBodyTypePictureClassFinder _bodyTypePictureClassFinder;
  
  public AdvancedController(IBodyTypeRepository bodyTypeRepository, IBodyTypePictureClassFinder bodyTypePictureClassFinder)
  {
      _bodyTypeRepository = bodyTypeRepository;
      _bodyTypePictureClassFinder = bodyTypePictureClassFinder;
  }
  
  [HttpGet]
  public ActionResult Index()
  {
      var advancedSearchViewModel = new AdvancedSearchViewModel();        
  
      return View(advancedSearchViewModel);
  }
  
  public ActionResult BodyTypes()
  {
      // this uses the repositories to create the ViewModel
  
      return View(bodyTypesViewModel);
  }
  </code></pre>
  
  <p>And the Index View:</p>
  
  <pre><code>&lt;div&gt;
      @Html.Action("BodyTypes","Advanced")   
  &lt;/div&gt;
  </code></pre>
  
  <p>If I execute this View I get the Message stated above. I also tried to remove the InstancePerHttpRequest or use RegisterControllers instead of regestering them explicitly, but that didn't work, too.
  If I use RegisterControllers I get the same Error. If I remove InstancePerHttpRequest it somehow executes the whole View two times, which is also not what I'd like to do ;)</p>
  
  <p>I hope anybody can help. This is a real Showstopper for me.</p>
  
  <p>Thansk a lot!!!!</p>
  
  <p>Regards,
  Florian Fanderl</p>