问题
While following along with Scott Allen's Pluralsight course, "Asp.net Core 1.0 Fundamentals", in the "Controllers in the MVC Framework" module and "Action Results" section I ran into a 406 Not Acceptable error on my Index action method that returned an ObjectResult with a model object.
回答1:
This blog post led me to making a reference to the IMvcCoreBuilder and adding the JSON formatter as follows:
public void ConfigureServices(IServiceCollection services)
{
var mvcCore = services.AddMvcCore();
mvcCore.AddJsonFormatters();
services.AddSingleton(provider => Configuration);
services.AddSingleton<IGreeter, Greeter>();
}
which allowed me to continue.
来源:https://stackoverflow.com/questions/38613714/returning-objectresult-results-in-406-not-acceptable