title: StructureMap with MVC and multiple layers
body: <p>I am using StructureMap.MVC5 and have the following projects and classes:</p>
  
  <pre><code>Web
      HomeController(PageService pageService)
  Services
      PageService(IPageRepository pageRepository)
  Repositories
      PageRepository : IPageRepository
  IRepositories
      IPageRepository
  </code></pre>
  
  <p>With the default implementation of StructureMap.MVC5 it automatically resolves the PageService into my HomeController, but not PageRepository into my PageService. This gives me the exception: <code>No parameterless constructor defined for this object.</code></p>
  
  <p>This is solved by adding a line to DefaultRegistry:</p>
  
  <pre><code>For&lt;IPageRepository&gt;().Use&lt;PageRepository&gt;();
  </code></pre>
  
  <p>But obviously I would rather have StructureMap automatically resolve this. Is there a way to achieve that?</p>
  
  <p>This is what the DefaultRegistry looks like:</p>
  
  <pre><code>public DefaultRegistry()
  {
      Scan(scan =&gt;
      {
          scan.TheCallingAssembly();
          scan.WithDefaultConventions();
          scan.With(new ControllerConvention());
      });
  }
  </code></pre>