Chapter 44ASP.NET Web API

WHAT’S IN THIS CHAPTER?

  • Overview of the ASP.NET Web API
  • Creating Services
  • .NET Clients
  • Web API Routing
  • Using OData
  • Security
  • Custom Hosting

WROX.COM CODE DOWNLOADS FOR THIS CHAPTER

The wrox.com code downloads for this chapter are found at www.wrox.com/go/procsharp on the Download Code tab. The code for this chapter is divided into the following major examples:

  • Book Service Sample
  • Formula 1 Data Service Sample
  • Secure Web API
  • Self-Host App

OVERVIEW

When Windows Communication Foundation (WCF) was announced, it was the technology for communication and replaced several other technologies in the .NET stack (a few mentioned are .NET Remoting and ASP.NET Web Services). The goal was to just have one communication technology that is very flexible and fulfills all needs. However, WCF was initially based on SOAP. Now we have many scenarios where the powerful SOAP enhancements are not needed. For simpler scenarios such as HTTP requests returning JSON, WCF is too complex. That’s why another technology was introduced in the year 2012: ASP.NET Web API. With the release of Visual Studio 2013, the next major version of ASP.NET Web API is released: 2.0. This version is covered in this chapter.

ASP.NET Web API offers a simple communication technology based on Representational State Transfer (REST). REST is an architecture style based on some constraints. Let’s compare a service that is based on the REST architectural style with a service that makes use of SOAP to see ...

Get Professional C# 5.0 and .NET 4.5.1 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.