title: Controllers split by areas
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/9485934/how-do-i-register-a-controller-that-has-been-created-in-an-area">How do I register a controller that has been created in an AREA</a>  </p>
  </blockquote>
  
  
  
  <p>I have the question - is it possible to do the next?</p>
  
  <p>I have three Areas:</p>
  
  <pre><code>_Default
  SiteOne
  SiteTwo
  </code></pre>
  
  <p>Inside each area i have a ApiController with the same name, but in different namespaces of course:</p>
  
  <pre><code>MvcAppliaction.Areas._Default.Controllers.ValuesController
  MvcAppliaction.Areas.SiteOne.Controllers.ValuesController
  MvcAppliaction.Areas.SiteTwo.Controllers.ValuesController
  </code></pre>
  
  <p>I also have a value of current (which i would like to use) Area in configuration.</p>
  
  <p>I would like to map user to controller in the proper Area (which i can find in the configuration) if he enters in the browser:</p>
  
  <pre><code>/api/values
  </code></pre>
  
  <p>For example, if current Area in config file is SiteOne then this request should be mapped to MvcAppliaction.Areas.SiteOne.Controllers.ValuesController controller, but if i change current Area in config file to SiteTwo of _Default it should be mapped to correct controller.</p>
  
  <p>PS. With MVC controller it's easy, you just have to set your route:</p>
  
  <pre><code>routes.MapRoute(
      name: "Default",
      url: "{controller}/{action}/{id}",
      defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
      namespaces: new[] { "MvcApplication.Web.Areas." + SiteName + ".Controllers") }
  );
  </code></pre>