We have three ways to return data and HTTP status codes from an action method in ASP.NET Core. You can return a specific type, return an instance of type IActionResult, or return an instance of type ActionResult. 

Although returning a specific type is the simplest way, IActionResult lets you return both data and HTTP codes, and ActionResult<T> lets you return a type that extends IActionResult. An ActionResult can be used to send an HTTP status code, data, or both from an action method.

This article presents a discussion of how we can return data in ASP.NET Core Web API using each of those types, with relevant code examples in C#. 

To work with the code examples illustrated in this article, you should have Visual Studio 2019 installed in your system. If you don’t already have a copy, you can download Visual Studio 2019 here

Create an ASP.Net Core API project