title: Serving Files and Routes from Web API
body: <p>We have an existing Web API project that we want to now serve 2 clients from root as well (accessed via different subdomains). What is the right way to setup Web API to perform the functions of serving files for two websites and hitting routes?</p>
  
  <p>I see two major options:</p>
  
  <ol>
  <li><p>Use Kestrel as a file server. I'm not sure how I would configure Kestrel to serve two sites from root (coming from different subdomains). It seems have minimal configuration exposed as is, and this doesn't seem extensible to serve 2 sites based on subdomain.</p>
  
  <pre><code>var host = new WebHostBuilder()
     .UseKestrel()
     .UseWebRoot("wwwroot")
     .UseIISIntegration()
     .UseStartup&lt;Startup&gt;()
     .Build();
  
  host.Run();
  </code></pre>
  
  <p>Furthermore, I'm currently having trouble integrating Kestrel with Web API, see this <a href="https://stackoverflow.com/questions/44143537/kestrel-with-iis-libuv-dll-missing-on-run">StackOverflow question</a>.</p></li>
  <li><p>Serve files from a Web API controller that is responsible for root. This would read the URL and return the proper index.html. From there I'm not sure how it would serve other files that index.html references, like js/app.js, css/core.css, or assets/*. Individual controllers could be made to handle these, but that seems fragile.</p></li>
  </ol>
  
  <p>Which of these approaches is appropriate? Or is there something else I have not considered to accomplish this end?</p>