Handling HTTP requests
ASP.NET provides a handy helper object for sending responses back to clients, called IResult.
An IResult contains properties that can be used to represent standard HTTP responses for many different scenarios. For example, we could use IResult to return a specific status code, return JSON data, or even trigger ASP.NET Identity provider functionality such as challenges and sign-in/out.
We can create a new IResult easily using ASP.NET’s Results factory class. In the preceding examples, you will have seen references to this factory class, where the API has returned status codes by calling Results.OK() and Results.Created(), to name a few.
Some of these simple HTTP status code methods have optional parameters that allow you to return strongly typed objects as JSON. For example, while you can simply return a 200 result by omitting any parameters in Results.OK(), you can also pass an object argument, and it will be sent back to the client. This was done...