加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

在发布asp.net Web API之后,ASP.NET MVC框架的未来是什么?

发布时间:2020-12-16 04:01:44 所属栏目:asp.Net 来源:网络整理
导读:我已经使用asp.net MVC大约1.5年了,我很享受它的功能,并且已经部署了许多成功的Web应用程序,但我现在正在阅读asp.net Web API技术.而且,我发现以下内容: 我可以实现我过去使用MVC实现的任何功能;使用新的Web API并采用更轻量级的方法. 使用Web API比较asp.n
我已经使用asp.net MVC大约1.5年了,我很享受它的功能,并且已经部署了许多成功的Web应用程序,但我现在正在阅读asp.net Web API技术.而且,我发现以下内容:

>我可以实现我过去使用MVC实现的任何功能;使用新的Web API并采用更轻量级的方法.
>使用Web API比较asp.net MVC更容易开发Web服务.

那么,asp.net Web API将来是否会接管asp.net MVC,或者每种技术都有自己的增长领域,或者我们是否应该考虑在同一个Web应用程序中使用它们?

解决方法

除了@jmoerdyk的答案,我想指出一些事情:

关键是要了解每种技术的目标:

> Web API.

这将是用于创建Web服务的新API,这是传统XML服务和WCF服务的替代方案,因此值得首先指出WEB API与其他Web服务框架之间的主要区别.

Web API和WCF / ASMX服务之间的主要区别在于它不基于SOAP它基于HTTP因此您可以利用所有HTTP功能,例如:

>它包含非常有意义和描述性的邮件标题 – 表示邮件正文内容类型的标题,解释如何缓存信息的标题,如何保护信息等.
>使用动词来定义动作(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包含主要呈现视图的附加功能.

您的担忧是基于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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读