Available starting with v1.9.0
Enabling output formatters support is a matter of:
public void ConfigureServices(IServiceCollection services)
{
services.AddViewModelComposition(options =>
{
options.ResponseSerialization.UseOutputFormatters = true;
});
services.AddControllers();
}
The required steps are:
- set
UseOutputFormatters
totrue
- Set up the MVC components by calling one of the following:
AddControllers()
AddControllersAndViews()
AddMvc
AddRazorPages()
The above configuration uses the new System.Text.Json
serializer as the default json serializer to format json responses. It's possible to plug-in the Newtonsoft Json.Net serializer output formatter by adding a package reference to the Microsoft.AspNetCore.Mvc.NewtonsoftJson
package, and using the following configuration:
public void ConfigureServices(IServiceCollection services)
{
services.AddViewModelComposition(options =>
{
options.ResponseSerialization.UseOutputFormatters = true;
});
services.AddControllers()
.AddNewtonsoftJson();
}