-
Notifications
You must be signed in to change notification settings - Fork 2.1k
How to set OutputFormatters in RTM #4965
Comments
You should call AddJsonOptions to configure the formatters settings you want to configure them. See https://github.com/aspnet/Mvc/blob/dev/src/Microsoft.AspNetCore.Mvc.Formatters.Json/DependencyInjection/MvcJsonMvcBuilderExtensions.cs and https://github.com/aspnet/Mvc/blob/dev/src/Microsoft.AspNetCore.Mvc.Formatters.Json/MvcJsonOptions.cs This will configure the settings for the input and the output formatters. If you want to configure only the settings for the output formatter you should remove the existing onE, new up another and add it to the list of output formatters in MVC options. Hope this helps. |
Is there a good reason why the |
I think in the AddMvcCore case its better to configure it when you call to AddJsonFormatter instead of adding another AddJsonOption method on IMvcCoreBuilder. The reason for this is that the following chain would be valid but produce an incorrect configuration. services.AddMvcCore()
.AddJsonOptions(options => ... ) The right thing to do would be services.AddMvcCore()
.AddJsonFormatter()
.AddJsonOptions() And at that point it will be simpler just to do services.AddMvcCore()
.AddJsonFormatters(settings => ...) |
How do I assign the various OutputFormatter members if they are now private members? in RC2 they were not
The text was updated successfully, but these errors were encountered: