Chapter 9. Creating a Web API for mobile and client applications using MVC

This chapter covers

  • Creating a Web API controller to return JSON to clients
  • Using attribute routing to customize your URLs
  • Generating a response using content negotiation
  • Enabling XML formatting

In the previous five chapters, you’ve worked through each layer of a traditional ASP.NET Core MVC application, using Razor views to render HTML to the browser. In this chapter, you’ll see a slightly different take on an MVC application. We’ll explore Web APIs, which serve as the backend for client-side SPAs and mobile apps.

You can apply much of what you’ve learned to Web APIs; they use the same MVC design pattern, and the concepts of routing, model binding, and validation ...

Get ASP.NET Core in Action 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.