42 ASP.NET Web API

What’s In This Chapter?

  • Overview of the ASP.NET Web API
  • Creating Web API controllers
  • Using repositories with dependency injection
  • Creating .NET clients calling REST APIs
  • Using Entity Framework from services
  • Creating Metadata using Swagger
  • Using OData

Wrox.com Code Downloads for This Chapter

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

  • Book Service Sample
  • Book Service Async Sample
  • Book Service Client App
  • Metadata Samples

Overview

When Windows Communication Foundation (WCF) was announced with .NET 3.0, it was the technology for communication and replaced several other technologies in the .NET stack (a few mentioned here are .NET Remoting and ASP.NET Web Services). The goal was to have one communication technology that is very flexible and fulfills all needs. However, WCF was initially based on SOAP (Simple Object Access Protocol). Nowadays 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 2012: ASP.NET Web API. With the release of ASP.NET MVC 6 and Visual Studio 2015, the third major version of ASP.NET Web API was released. ASP.NET MVC and ASP.NET Web API previously had different types and configurations (the previous versions were ASP.NET MVC 5 and ASP.NET ...

Get Professional C# 6 and .NET Core 1.0 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.