什么是ASP.NET MVC框架的未来释放asp.net的Web API后, [英] What is the future of ASP.NET MVC framework after releasing the asp.net Web API

查看:273
本文介绍了什么是ASP.NET MVC框架的未来释放asp.net的Web API后,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用asp.net MVC周边的5年,很喜欢它的能力,已经部署了许多成功的Web应用程序,但我目前正在阅读有关asp.net的Web API技术。而且,我发现以下内容:


  1. 我可以实现我用使用MVC实现任何功能;使用新的Web API,并在一个更轻量级的方法。


  2. 这是比较容易使用Web API比较asp.net MVC开发Web服务。


所以,将asp.net的Web API接管asp.net MVC在未来,或者每个技术将有自己的区域增长,或者我们应该考虑在同一个Web应用程序同时使用他们?


解决方案

除了@ jmoerdyk的答案,我想点东西出来:

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


  • 的Web API。

    这将是用于创建Web服务的新API,这是传统的XML服务和WCF服务的替代品,所以它值得指出的第一个Web API和Web服务框架的其余部分之间的主要区别。

    网页API和WCF / ASMX服务之间的主要区别是,它不是基于SOAP它是基于HTTP 因此你可以利用所有的HTTP的功能,如优势:


    • 它包含有非常有意义的描述性消息头 - 这表明消息的​​正文的内容类型标题,说明如何缓存信息,如何确保它等标题

    • 使用动词来定义操作(POST,PUT,DELETE。)

    • 它包含可用于发送任何类型的内容的主体

    • 它使用URI识别这两种信息路径(资源)和动作


      

    这是该Web API的主要目标,即当年的WCF的Web的API:停止通过WCF的眼睛看着HTTP - 只是一个传输协议来传递请求。相反,它可以让我们看它作为真正的应用层协议是 - 一个丰富的,可互操作的,面向资源的协议。该Web API的目的是正确地使用URI,HTTP头,和身体为Web创建HTTP服务,并为其他人的希望拥抱HTTP作为其协议和终身的朋友。


    看看这篇文章的更多信息:<一href=\"http://www.$c$cproject.com/Articles/341414/WCF-or-ASP-NET-Web-APIs-My-two-cents-on-the-subjec\">http://www.$c$cproject.com/Articles/341414/WCF-or-ASP-NET-Web-APIs-My-two-cents-on-the-subjec

    所以基本上在Web API实际上可以对WCF或XML服务相比

    如果你想知道这是怎么回事与WCF发生?


      

    所以,事实是,我们有太多的选择,因此太多的混乱。什么是我们该怎么办?我们的团队合并! (种提醒我们的LINQ到SQL和Entity Framework,WCF和Ado.Net数据服务和其他这样的例子的时间)。因此,WCF团队和ASP.NET团队强强联手,创造了专注于REST /超媒体/ HTTP服务天下为网络世界的新框架,从而走出的ASP.NET Web API的。



  • MVC

    现在,你知道什么是网络API的目标,那么它应该是比较容易的的MVC为什么包含更多的功能来呈现的意见为主。

    您的关注是基于一个事实,即WEB API为实际上是基于MVC ,但他们的目标是不同的。


      

    在另一方面,在ASP.NET MVC的基础设施,其优雅的处理HTTP请求和响应,其支持易于创建控制器似乎是正确的方式去建立这种新型的服务



I have been using asp.net MVC for around 1.5 years, am enjoying its capabilities, and have deployed many successful web applications, but I'm currently reading about the asp.net Web API technology. And, I find the following:

  1. I can implement any functionality that I used to implement using MVC; using the new Web API and in a more lightweight approach.

  2. It is easier to develop web services using the Web API comparing the asp.net MVC.

So, will the asp.net Web API take over asp.net MVC in the future, or each technology will have its own area to grow in, or should we consider using both of them in the same web application?

解决方案

Besides the @jmoerdyk's answer, I would like to point something out:

The key is to understand the goal of each technology:

  • Web API.

    This will be the new API for creating web services, this is an alternative to traditional XML services and WCF services, so it's worth pointing out first the main difference between WEB API and the rest of the Web service frameworks.

    The primary difference between Web API and WCF/ASMX services is that it's not based on SOAP it's based on HTTP Therefore you can take advantage of all the HTTP features like:

    • It contains message headers that are very meaningful and descriptive - headers that suggest the content type of the message’s body, headers that explain how to cache information, how to secure it etc.
    • use of verbs to define the actions (POST, PUT, DELETE..)
    • it contains a body that can be used to send any kind of content
    • It uses URIs for identifying both information paths (resources) and actions

    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.

    Take a look to this article for more information: http://www.codeproject.com/Articles/341414/WCF-or-ASP-NET-Web-APIs-My-two-cents-on-the-subjec

    So basically the Web API could actually be compared against WCF or XML Services

    If you are wondering what's going to happen with 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

    Now that you know what's the goal of the Web API, then it should be easier to say why MVC contains additional functionality to render views primarily.

    Your concern is based on the fact that WEB API is actually based on MVC, but their goals are different

    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 MVC框架的未来释放asp.net的Web API后,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆