What is ASP. NET Web API?

Source: Internet
Author: User
Tags what is asp

What is the "translate" ASP?

Description: A framework was released with Microsoft ASP 41, called the ASP. At present, the domestic attention to this technology seems to be very few people, this aspect of the article is rare. Developing a Web application may be possible with techniques such as MVC, rather than the Web API technology, but, if used, will bring great benefits to your application. To this end, I reproduced and translated the following this article, there will be a succession of translation of the technology of some official tutorials. We learn together and improve together.

Microsoft ASP.NET:What ' s This New Web API?
Microsoft asp: What is the new Web API?

Excerpt from: http://www.devproconnections.com/article/asp/microsoft-aspnet-web-api-142516

Don Kiely explains why Microsoft's Web API shines as a new technology for developers
Don Kiely explains why Microsoft's Web API is a dazzling new technology for developers.

Don Kiely
Dev Pro
InstantDoc ID #142516
March, 9:00AM

After a respite in the from new product mania, Microsoft are on a tear in the release early versions for many of it s development tools. In the past couple of weeks we ' ve seen a preview for Visual Studio and ASP. NET MVC 4. We also got our first look at the SQL Server Release candidate. These new releases mark an exciting time for technology, even if it means reevaluating these technologies and determining What skills developers should learn and focus on.
After 2011 new Product mania, Microsoft launched a number of early versions of many development tools in 2012. In the last few weeks we saw a preview of visual Studio 2011 and ASP. NET MVC 4. We also got a pre-release version of SQL Server 2012. These latest releases mark the exciting moment of technology, although this only means a reassessment of these technologies and determines which skills developers should learn and focus on.

One truly new and exciting technology for Microsoft is the Web API. I wasn ' t initially enthusiastic about this API, because it seemed to being another Web service that's similar to the RESTful Api. Do we really need another API if we already have ASP. NET Web Services and Windows communication Foundation (WCF), or has Microsoft Gone nutty about these kinds of APIs just as it have with data-access APIs?
A truly new and exciting Microsoft technology is the Web API. I didn't really like this API at first because it seemed to be just another Web service similar to the rest of the API. Do you really need another API when you already have ASP. NET Web Services (ASP) and Windows Communication Foundation (Windows Communications Foundation-WCF)? Or is Microsoft already in the frenzy of making APIs like it does with data access APIs?

I won ' t address the last part of this question-microsoft seems pretty nutty at Times-but I ' m really starting to warm up To the new Web API, particularly because it's solidified into what appears to be the actual release API. I ' ve come to realize, the reason for this is, the Web API feels natural and seems to fit in with the kinds of APPL Ications that I build. The web API is far more than the relatively basic and hard-to-secure ASP. NET Web Services and the mind-numbingly complex W CF that all feels like a gross overkill for most things a website needs to do. At least this situation are true for the kinds of applications, I build most often these days.
I didn't notice the latter part of the problem-Microsoft was sometimes quite crazy-but I really started to love this new Web API. I'm starting to realize that the reason for this is that the Web API feels natural, and it seems to fit into the various applications I've built. The Web API goes far beyond the relatively basic and hard-to-secure ASP. And the extremely complex WCF always feels like a sledgehammer for a Web site. At least, this is true for the various applications that I have built most often these days.

I ' ve outlined some pretty subjective reasons for what I like the new Web API. From a objective and raw technology perspective, the Web API is designed and lives for HTTP. One complex problem with WCF is so it provides everything for everyone for every transport protocol, as Matt Milner expl Ains in his blog post. You have the to do some work with WCF over HTTP. In contrast, the Web API was designed from the ground up to make good use of HTTP, warts and all. The Web API isn ' t exactly lightweight, but with only one protocol to support the API, it doesn ' t has a lot of excess bagg Age.
I outline some quite subjective reasons why I like this new Web API. From an objective and primitive point of view, the Web API is designed and exists for HTTP. A complex problem with WCF is that it provides everything in every transmission protocol, as Matt Milner in his blog post explains. You have to do some work to apply WCF to HTTP. In contrast, Web APIs are designed to be built around the full use of HTTP, without reservation. The Web API is not lightweight, but it only supports the API for one protocol, which does not create a lot of overweight baggage.

The other thing, I like about the Web API is, it reflects the direction in which, the Web is headed. As Scott Guthrie points out in the first part of the He blog post series about the Web API, many large websites is exposing Web APIs to make their services available to Third-party applications (he cites Facebook, Twitter, LinkedIn, and Netflix a s examples). He also lists a bunch of reasons why a Web API is a good solution, including a modern HTTP programming model. It ' s about time Microsoft got around to providing this model! The other thing
I like about Web APIs is that it reflects the direction the web is going forward. As Scott Guthrie in his first installment of the Web API series (Chinese version URL: http://blogs.msdn.com/b/scottgu/archive/2012/03/26/ asp-net-web-api.aspx) points out that many large Web sites expose Web APIs to enable third-party applications to use their services (he illustrates Facebook, Twitter, LinkedIn, and Netflix). He also lists a dozen reasons why the Web API is a good solution, including a "Modern HTTP programming model". Now it's time for Microsoft to provide this model!

I love the close integration of the Web API with ASP. Microsoft chose to implement custom Web APIs by using the well-established controller model. This makes sense because a lot of people were already implementing custom Web APIs by using MVC controllers that return JS On data to the client. That ' s a slick solution, and the Web API just makes it better. The only big difference are a WEB API controller implements Apicontroller class instead of controller class, which in Turn implements the Ihttpcontroller interface. Apicontroller is a relatively simple class in the System.Web.Http namespace, so it isn ' t tied exclusively to ASP. But it understands the HTTP protocol and most of its common verbs.
I like the close integration of Web APIs with ASP. Microsoft chooses to implement a custom Web API by using a well-established controller model. This is meaningful because many people have implemented custom Web APIs by using MVC's controller to return the JSON data to the client. This is a smooth solution, and the Web API just makes it better. The only big difference is that the Web API controller implements the Apicontroller class instead of the Controller class, which in turn implements the Ihttpcontroller interface. Apicontroller is a relatively simple class in the System.Web.Http namespace, so it is not specifically bound to ASP. NET MVC, but it can understand the HTTP protocol and most of its general predicates.

Best of all, the APIs are available to a wide variety of clients, including mobile applications. In fact, this fact is probably it biggest selling point. Web applications is increasingly not limited to applications this run in a desktop browser.
The best reason is that this API can be used for a very wide range of clients, including mobile applications. In fact, this fact may be its biggest selling point. Web applications are increasingly not limited to applications running on desktop browsers.

I ' m not as big a fan of Microsoft's Web API as I am of the Entity Framework, but I can already feel the tug. It ' ll be interesting-see how widely used the new technology becomes when it's finally released, but the right now Web API Is looking like a winner.
I'm a big fan of the Entity Framework and not the Microsoft Web API, but I've been able to feel this pull. It's interesting to see that new technology becomes widely available when it's finally released, and now the Web API seems like a winner.

Why use the Web API

The most important thing about Web APIs is the ability to build services for a variety of clients. In addition, unlike the WCF REST service, the Web API uses various aspects of the HTTP protocol to express services (such as uri/request response header/caching/versioning/content format). Therefore, many configurations are omitted.

When you encounter these situations, you can consider using the Web API.

    • Requires a Web service but does not require soap
    • Need to establish non-soap-based HTTP service on the basis of existing WCF services
    • Just want to publish some simple HTTP service, do not want to use the relatively complex WCF configuration
    • The published service may be accessed by a bandwidth-constrained device
    • Want to use the open source framework, when it is critical to debug or customize the framework

Key Features

Key features of the Web API

    • Support for CRUD (create, retrieve, update, delete) operations based on HTTP verb (GET, POST, PUT, delete). The different meanings are expressed by different HTTP actions, so there is no need to expose multiple APIs to support these basic operations.
    • The requested reply expresses a different meaning through the HTTP Status code, and the client can negotiate the format with the server via the accept header, such as whether you want the server to return a JSON format or an XML format.
    • The requested reply format supports Json,xml and can be extended to add additional formats.
    • Native support OData.
    • Support for Self-host or IIS host.
    • Supports most MVC features, such as Routing/controller/action Result/filter/model builder/ioc container/dependency Injection.


You might think that Web APIs are very similar to MVC, and what are the differences between them?

To point out their differences in detail,

    • MVC is primarily used to build web sites that care about data as well as page presentation, while Web APIs focus only on data
    • The WEB API supports format negotiation, and clients can notify the server of the desired format via the Accept header
    • Web API Support Self HOST,MVC not currently supported
    • The Web API expresses different actions (CRUD) through different HTTP verb, and MVC expresses the action by the action name
    • The Web API is built into the ASP. Net System.Web.Http namespace, MVC is located under the System.Web.Mvc namespace, so features such as model binding/filter/routing are different
    • Finally, the Web API is ideal for building mobile client Services

Web API and WCF

What is the choice between the Publishing service and the Web API and WCF? Here are a few simple rules to judge,

    • If the service needs to support one-side messaging/message queue/duplex communication, select the WCF
    • If the service requires tcp/named PIPES/UDP (WCF 4.5), select the WCF
    • If the service needs to be on the HTTP protocol, and you want to take advantage of the various features of the HTTP protocol, select the Web API
    • If the service needs to be called by various clients (especially mobile clients), select the Web API



A simple series of summaries and lists, which is also a very large project. For the time being, I have learned to translate six courses, and I feel that some of the knowledge points and ASP. NET MVC have relatively high similarity, which also gives me a deeper understanding of some problems in MVC. Hope to have more friends to participate in them.

What is ASP. NET Web API?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.