gpt4 book ai didi

asp.net - ASP.NET Web API 发布后 ASP.NET MVC 框架的 future 是什么

转载 作者:行者123 更新时间:2023-12-04 01:32:58 25 4
gpt4 key购买 nike

我已经使用 asp.net MVC 大约 1.5 年了,我很享受它的功能,并且已经部署了许多成功的 Web 应用程序,但我目前正在阅读有关 asp.net Web API 技术的信息。而且,我发现以下内容:

  • 我可以实现以前使用 MVC 实现的任何功能;使用新的 Web API 和更轻量级的方法。
  • 与 asp.net MVC 相比,使用 Web API 开发 Web 服务更容易。

  • 那么,将来asp.net Web API会取代asp.net MVC,还是每种技术都有自己的发展领域,还是应该考虑在同一个Web应用程序中同时使用它们?

    最佳答案

    除了@jmoerdyk 的回答,我想指出一些事情:
    关键是要了解每项技术的目标:

  • 网页 API。
    这将是用于创建 Web 服务的新 API,这是传统 XML 服务和 WCF 服务的替代方案,因此首先需要指出 WEB API 与其他 Web 服务框架之间的主要区别。
    Web API 和 WCF/ASMX 服务之间的主要区别在于 它不是基于 SOAP,而是基于 HTTP 因此,您可以利用所有 HTTP 功能,例如:
  • 它包含非常有意义和描述性的消息头 - 建议消息正文内容类型的头,解释如何缓存信息,如何保护信息等的头。
  • 使用动词来定义 Action (POST、PUT、DELETE..)
  • 它包含一个可用于发送任何类型内容的主体
  • 它使用 URI 来标识信息路径(资源)和操作

  • That was the main goal of the Web APIs, known back then as the WCF Web APIs: to stop looking at HTTP through the eyes of WCF - as just a transport protocol to pass requests. Rather, it allows us to look at it as the real application-level protocol it is – a rich, interoperable, resource-oriented protocol. The purpose of the Web APIs was to properly use URIs, HTTP headers, and body to create HTTP services for the web, and for everyone else that wished to embrace HTTP as its protocol and lifelong friend.


    查看这篇文章了解更多信息: http://www.codeproject.com/Articles/341414/WCF-or-ASP-NET-Web-APIs-My-two-cents-on-the-subjec
    所以基本上 Web API 实际上可以与 WCF 或 XML 服务进行比较
    如果您想知道 WCF 会发生什么?

    So the fact was we had too many options and therefore too much confusion. What were we to do? We merge teams! (Kind of reminds us of the time of LINQ-to-SQL and Entity Framework, WCF and Ado.Net Data Services and other such examples). So the WCF team and the ASP.NET team joined forces and created a new framework focused on the world of REST/Hypermedia/HTTP services for the web world and thus came out the ASP.NET Web APIs.


  • MVC
    既然您知道 Web API 的目标是什么,那么应该更容易说明为什么 MVC 包含主要呈现 View 的附加功能。
    您的担心是基于WEB API是的事实。实际上基于MVC ,但他们的目标不同

    On the other hand, the ASP.NET MVC infrastructure with its elegant handling of HTTP requests and responses, and its support of easy-to-create controllers seemed like the proper way to go for creating this new type of services


  • 关于asp.net - ASP.NET Web API 发布后 ASP.NET MVC 框架的 future 是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11621550/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com