14.01.2015 Views

Eric lippert - Amazon Web Services

Eric lippert - Amazon Web Services

Eric lippert - Amazon Web Services

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

We can edit this by clicking on the ‘Select’ link<br />

We update the Summary and Description before hitting ‘Save’, the<br />

data gets updated in the DB<br />

The next POST request pushes JSON Data to the Server.<br />

Behind the Scenes<br />

On the next load, we again do a GET request and we see an array<br />

of JSON objects is returned, it has the newly created object in it.<br />

Now that we’ve seen what’s happening in the UI, let’s see what’s<br />

happening behind the scenes. To look at the HTTP Traffic, I had<br />

kept Fiddler running and the first request in Fiddler is a GET<br />

request which as we can see below, gets an empty JSON in return.<br />

In each of the cases, if you see the ‘Content-Type’ header<br />

parameter, it’s set to Content-Type: text/json because we are<br />

requesting for the JSON data or posting JSON data. The <strong>Web</strong> API<br />

service can serve JSON and XML, it sees a request for JSON and<br />

uses the JSON formatter to convert the Entity or Entity List into<br />

JSON. It’s worth noting that in our API Controller, we return<br />

Domain entities or their lists directly. Note the GetTimeCards and<br />

the GetTimeCard methods below.<br />

namespace TimeKeepr.Models<br />

{<br />

public class TimeCardController : ApiController<br />

68 | DNCmagazine www.dotnetcurry.com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!