Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

asp.net-core

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?

like image 716
Fernando Lopes Avatar asked Nov 27 '17 10:11

Fernando Lopes


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.

like image 57
SpruceMoose Avatar answered Nov 18 '22 15:11

SpruceMoose