I had the same thought as soon as the first conversation about the web API was around. In short, the Web API is a new product from MS.NET Web Stack that is built on top of WCF, OData, and MVC to provide a single way to create a RESTful Web API. A lot of resources on this, so you have Google.
Now to the question ..
The problem is that you can of course force the web API to return HTML, JSON, XML, etc., but the missing part here are the views / templates provided by Razor / ASPX / insertviewenginehere. This is not really the work of the "API".
Of course, you could write client-side code to call your web API and run the templating / UI client program with the massive number of plugins available.
I am sure that the web API is not capable of returning template HTML in the same way as the ASP.NET MVC web application can do.
Therefore, if you want to "reuse" certain parts of your application (repository, domain, etc.), it would be best to wrap the calls in the facade / services style and make both your web API and a separate web application ASP.NET MVC to reduce code.
All you need to do is an ASP.NET MVC web application that calls your domain and creates template HTML, and an ASP.NET Web API application that calls your domain and returns various resources (JSON, XML, etc. ).).
If you have a well-structured application, then this form of abstraction should not be a problem.
RPM1984
source share