Is it true that \"ApiController
will get deprecated in .NET Core\"? Asking since I\'m planning to use it in new projects.
In ASP.NET core uses terms and concepts known from ASP.NET MVC and ASP.NET WepAPI. But basically it is a complete new framework. Therefore there are several concepts or base classes that we can simply forget.
ASP.NET MVC and ASP.NET WebApi are two coexisting but different frameworks and therefore a destinction has to be made to specify a controller as a WebApi Controller by using the ApiController
as base class.
In ASP.NET Core this is simply not necessary anymore. The Controller
base class can be used for actions that return HTML from Razor Views or JSON (with output formatters XML and other formats are possible as well). You don't even need the Controller
base class. It is even possible to use a "Plain Old C# Object" as Controller without inheritence.
This is an example of a Demo-Controller to outline, that even though the ApiController is not there, the structural approach to deliver data to the client is similar.
public class DemoController : Controller
{
public async Task Action()
{
var model = await _someService.GetPreciousData();
return Ok(model);
}
}