Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Returning ObjectResult results in 406 Not Acceptable

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.

like image 663
Dzejms Avatar asked Jul 27 '16 13:07

Dzejms


1 Answers

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.

like image 57
Dzejms Avatar answered Nov 15 '22 22:11

Dzejms