Getting ready

By default, ASP.NET Core will return JSON from action methods.

Let's get the code from the previous recipe, and let's see the result from GetAllProducts:

We get JSON values, because by default, ASP.NET Core doesn't take into account the Accept header the browser sent.

Get ASP.NET Core MVC 2.0 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.