What is the purpose of AddFormatterMappings() on Asp.net Core 2

Viewed 1821

I am evaluating the configuration of a Web API App with Asp.Net Core 2. To configure I know it is better for my project to use .AddMvcCore() rather then use AddMvc() since I don't need Razor as we can see here.

Now, I am not sure if I also need this .AddFormatterMappings(). So my question is what is it for?

1 Answers

You can see from the source code in the MVC GitHub repo that it adds a FormatFilter service into the DI setup. The summary for the FormatFilter class is as follows:

A filter that will use the format value in the route data or query string to set the content type on an ObjectResult returned from an action.

Related