20 Creating an HTTP API using web API controllers

This chapter covers

  • Creating a web API controller to return JavaScript Object Notation (JSON) to clients
  • Using attribute routing to customize your URLs
  • Generating a response using content negotiation
  • Applying common conventions with the [ApiController] attribute

In chapters 13 through 19 you worked through each layer of a server-side rendered ASP.NET Core application, using Razor Pages and Model-View-Controller (MVC) controllers to render HTML to the browser. In part 1 of this book you saw a different type of ASP.NET Core application, using minimal APIs to serve JSON for client-side SPAs or mobile apps. In this chapter you’ll learn about web API controllers, which fit somewhere in between!

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