Available starting with v1.9.0
Enabling output formatters support is a metter of:
public void ConfigureServices(IServiceCollection services)
{
services.AddViewModelComposition(options =>
{
options.ResponseSerialization.UseOutputFormatters = true;
});
services.AddControllers();
}
The required steps are:
UseOutputFormatters
to true
AddControllers()
AddControllersAndViews()
AddMvc
AddRazorPages()
The above configuration uses the new System.Text.Json
serializer as the default json serializer to format json responses. The System.Text.Json
serializer does not support serializing dynamic
objects. It’s possible to plug-in the Newtonsoft Json.Net serializer as 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();
}