Chapter 11ASP.NET Web API

—by Brad Wilson

What's In This Chapter?

  • How to define ASP.NET Web API
  • Using the new ASP.NET Project wizard
  • The basics of writing an API controller
  • Configuring web-hosted and self-hosted Web API
  • How to add Web API and MVC routing
  • How to bind parameters
  • How to filter requests
  • How to enable dependency injection
  • Programmatically exploring APIs
  • How to trace the application
  • ProductsController: A real-life example


You can find the code downloads for this chapter at on the Download Code tab. This download contains the completed project for this chapter.

During the late ‘90s, web development started shifting from static content to active content and applications, using server-based technologies such as CGI, Active Server Pages (ASP), Java, and PHP. This shift ignited a transformation that is ongoing today: moving applications—especially IT applications in businesses—from the desktop and into the browser. A major accelerator of that shift was XMLHTTP, originally shipped with Internet Explorer 5, which when combined with JavaScript, allowed web developers to communicate back from their browser applications to the server. Google showed the world what was possible with applications, such as Google Maps and Gmail, and now the world is awash in browser-based applications.

Early versions of ASP.NET MVC included the ability to write controllers that behaved more like APIs than web ...

Get Professional ASP.NET MVC 5 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.