CHAPTER 3

image

Media-Type Formatting CLR Objects

From the ASP.NET Web API perspective, serialization is the process of translating a .NET Common Language Runtime (CLR) type into a format that can be transmitted over HTTP. The format is either JSON or XML, out of the box. A media type formatter, which is an object of type MediaTypeFormatter, performs the serialization in the ASP.NET Web API pipeline. Consider a simple action method handling GET in an ApiController:

public Employee Get(int id){       return list.First(e => e.Id == id);} 

This method returns a CLR object of type Employee. In order for the data contained in this object to be returned ...

Get Practical ASP.NET Web API 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.