【问题标题】:ASP.NET Web Api as a standalone project in one solutionASP.NET Web Api 作为一个解决方案中的独立项目
【发布时间】:2012-04-25 18:01:13
【问题描述】:

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

我不希望 ApiController(s) 与我的 MVC 项目在同一个项目中,所以我需要添加一个新的 WebApi 项目(删除除控制器和模板添加的所有内容之外的所有内容以拥有一个干净的项目)我的 MVC 应用程序会引用吗?

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

ASP.NET Web API - 带有可下载示例代码的截屏系列 http://weblogs.asp.net/jgalloway/archive/2012/03/16/asp-net-web-api-screencast-series-with-downloadable-sample-code-part-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/consuming-asp-net-web-api-service-using-httpclient-part2-of-many/

使用 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-web-api-odata-services/

使用 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

http://thedatafarm.com/blog/asp-net/how-i-see-web-api/

【问题讨论】:

    标签: c# asp.net-mvc-4 asp.net-web-api


    【解决方案1】:

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

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

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

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

    【讨论】:

    猜你喜欢
    • 2012-10-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-20
    • 2020-08-19
    • 1970-01-01
    • 2015-06-05
    • 2013-09-06
    相关资源
    最近更新 更多