ASP.NET Web Api作为一个解决方案中的独立项目

如果我想使用WebAPI作为服务连接到不同服务器上的多个数据库并检索我的MVC应用程序将使用的数据,那么最好的方法是什么?

我不希望ApiController与我的MVC项目在同一个项目中,所以我需要添加一个新的WebApi项目(删除所有除了控制器和模板添加的东西都有一个干净的项目)我的MVC应用程序会参考吗?

这是我用来了解WebAPI的教程/博客文章列表:

ASP.NET Web API – 具有可下载示例代码的Screencast系列 http://weblogs.asp.net/jgalloway/archive/2012/03/16/asp-net-web-api-screencast-series-with-downloadable-sample-码部分1.aspx

使用HttpClient使用ASP.NET Web API服务

http://debugmode.net/2012/03/03/creating-first-http-service-using-asp-net-web-api-part1-of-many/ http://debugmode.net/2012/03/ / 07 /使用-HttpClient的-第2部分-的-许多消费-ASP网的Web-API服务

使用ASP.NET Web API和MVC4的CRUD操作

http://www.dotnetglobe.com/2012/03/crud-operation-using-aspnet-web-api-in.html http://www.dotnetglobe.com/2012/03/crud-operation-using-aspnet -Web-API in_28.html

为ASP.Net Web API oData服务创建.Net可查询客户端 http://blog.petegoo.com/index.php/2012/03/11/creating-a-net-queryable-client-for-asp-net-网上API-的OData服务/

使用HttpClient来使用ASP.NET Web API REST服务 http://www.johnnycode.com/blog/2012/02/23/consuming-your-own-asp-net-web-api-rest-service/

使用ASP.NET Web API的客户端支持 https://msmvps.com/blogs/theproblemsolver/archive/2012/03/13/client-side-support-with-the-asp-net-web-api.aspx

创建和使用ASP.Net Web API REST服务 – MVC4 http://www.askamoeba.com/Opensource/Opensourcedetail/144/Create-and-Consume-ASP-Net-Web-API-REST-Services-MVC4

使用MediaTypeFormatter和OData支持使用ASP.NET Web API构建和使用REST服务

http://robbincremers.me/2012/02/16/building-and-consuming-rest-services-with-asp-net-web-api-and-odata-support/

将JSON.NET与ASP.NET Web API结合使用

http://blogs.msdn.com/b/henrikn/archive/2012/02/18/using-json-net-with-asp-net-web-api.aspx

在ASP.NET Web API中为逗号分隔值(CSV)格式创建自定义CSVMediaTypeFormatter

http://www.tugberkugurlu.com/archive/creating-custom-csvmediatypeformatter-in-asp-net-web-api-for-comma-separated-values-csv-format

在ASP.NET Web API中实现CORS支持

http://blogs.msdn.com/b/carlosfigueira/archive/2012/02/20/implementing-cors-support-in-asp-net-web-apis.aspx

我如何看待Web API

How I see Web API

您可以使用完全不同的项目来托管Web API控制器。 但在这种情况下,您需要考虑部署。

Web API只是一个Web项目。 它将有自己的配置文件。 它可能会在自己的工作进程中运行(取决于您如何部署它)。

因此,如果您将Web API分区,那么您将获得更大的灵活性,但最终可能会复制大量配置。

我的建议是,如果你这样做,请确保两个项目都与相同的基础服务项目进行对话。 如果第三方可能使用此Web API,则分区也很有意义。