O'Reilly logo

Expert ASP.NET Web API 2 for MVC Developers by Adam Freeman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 12

image

Creating Media Type Formatters

Media type formatters are the component responsible for serializing model data so that it can be sent to the client. In this chapter, I explain how media type formatters work by creating a custom data format and using it to explain the different ways in which a formatter can be applied. Table 12-1 summarizes this chapter.

Table 12-1. Chapter Summary

Problem

Solution

Listing

Create a media type formatter.

Derive from the MediaTypeFormatter class and implement the CanReadType, CanWriteType, and WriteToStreamAsync methods.

1–3

Register a media type formatter.

Add an instance of the custom class to the formatter ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required