问题
I have an MVC application and the solution consist of three project as described below:
Store.Domain : Holds the domain entities and logic (repositories created with the Entity Framework).
Store.WebUI : Holds the controllers and views; acts as the UI for the application.
Store.UnitTests : Holds the unit tests for the other two projects.
I will use WebAPI 2 in my application in order to create web services for some of the Android applications. Now I am not sure about the issues below:
1) By keeping in mind security and maintenance concerns, should I create a separate project for WebAPI or use WebAPI in the Store.WebUI project? As I will also install WebAPI documentation nuget and it will create several folders and files in the project, I think creating a new project maybe better.
2) Assuming to create a new project dedicating for WebAPI, what would be the project type and choices for the WebAPI project? Is it true the following selections as indicated on the screenshot?
Project Type: ASP.NET Web Application
Project Template: Just select Web API
Thanks in advance.

回答1:
WebApi is an alternative Service oriented application from Microsoft just like WCF. But WCF uses SOAP protocol and WebAPI uses HTTP protocol for communication.
So if you are using WEBAPI to provide service for your MVC application you would host that WEB API service seperately and consume its service by MVC application,
If you want them (MVC and WebAPI) to use in the same project, follow this rules from this article.
Hope that helps.
来源:https://stackoverflow.com/questions/30330403/what-are-the-pros-and-cons-of-having-a-webapi-in-the-same-or-different-project