Skip to Content
Programming ASP.NET MVC 4
book

Programming ASP.NET MVC 4

by Jess Chadwick, Todd Snyder, Hrusikesh Panda
September 2012
Intermediate to advanced
488 pages
13h 28m
English
O'Reilly Media, Inc.
Content preview from Programming ASP.NET MVC 4

Chapter 7. The ASP.NET Web API

As your application’s client-side UI grows beyond a few simple AJAX requests, you may begin to find that ASP.NET MVC’s JsonResult-based controller actions don’t quite meet the needs of an advanced AJAX frontend. When this happens, it may be time to look for a more simple and elegant way to handle advanced AJAX requests. It may be time to start using the ASP.NET Web API.

The ASP.NET Web API Framework leverages both web standards—such as HTTP, JSON, and XML—and a standard set of conventions to provide a simple way to build and expose REST-based data services. From an architectural standpoint, the ASP.NET Web API is very similar to ASP.NET MVC in that it leverages some of the same core concepts, such as routing, controllers, and even controller action results. It uses these concepts, however, to support a very different set of scenarios: scenarios that involve working with data as opposed to generating HTML markup.

This chapter gives you a basic introduction to the ASP.NET Web API Framework, showing you how to create and expose ASP.NET Web API services, then consume those services via AJAX from a browser.

Building a Data Service

Adding an ASP.NET Web API controller to your application is almost exactly like adding an ASP.NET MVC controller. The following sections walk you through the process by showing how you can add a Web API controller to the Ebuy reference application.

Before you begin, you’ll need a folder in which to store your new Web API controller. ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

ASP.NET MVC 4 in Action

ASP.NET MVC 4 in Action

Eric Hexter, James Bogard, Jeremy Skinner, Jeffrey Palermo, Matthew Hinze
Professional ASP.NET MVC 2

Professional ASP.NET MVC 2

Jon Galloway, Phil Haack, Scott Hanselman, Scott Guthrie, Rob Conery
Professional ASP.NET MVC 4

Professional ASP.NET MVC 4

Jon Galloway, Phil Haack, Brad Wilson, K. Scott Allen, Scott Hanselman

Publisher Resources

ISBN: 9781449321932Errata Page