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?
I see two major options:
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.
var host = new WebHostBuilder() .UseKestrel() .UseWebRoot("wwwroot") .UseIISIntegration() .UseStartup<Startup>() .Build(); host.Run();
Furthermore, I'm currently having trouble integrating Kestrel with Web API, see this StackOverflow question.
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.
Which of these approaches is appropriate? Or is there something else I have not considered to accomplish this end?