In ASP.NET Core WebAPI, action injection refers to the process of injecting services directly into a controller's action methods. It enables you to get the services needed for a specific action method without having to inject them into the controller's constructor.

Services are often injected into a controller's constructor and are available for use throughout all action methods inside that controller in traditional dependency injection (DI). However, there may be times when you simply require a service within a specific action method. In such cases, action injection can be used to directly inject the required service into the method's argument.

In ASP.NET Core, the attribute '[FromServices]' is used to inject services straight into action methods of your controllers.

The [FromServices] attribute for action injection has been available since the initial release of ASP.NET Core, which is ASP.NET Core 1.0. It has been a part of the framework since its inception and is used to inject services directly into action methods within controllers.

Here is a way to employ the [FromServices] attribute within an ASP.NET Core WebAPI controller:

The tools which I have leveraged for this tutorial.
    VS 2022 Community Edition
    .NET 6.0
    Web API
Define a service interface and its implementation:
public interface IMyService
{
    string GetServiceInfo();
}

public class MyService : IMyService
{
    public string GetServiceInfo()
    {
        return "Example on Action Injection";
    }
}


Configure the service in your Program.cs:
builder.Services.AddTransient<IMyService, MyService>();

Use [FromServices] attribute in your controller action method:
namespace ActionInjection.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class MyController : ControllerBase
    {
        [HttpGet("info")]
        public IActionResult GetInfo([FromServices] IMyService myService)
        {
            var info = myService.GetServiceInfo();
            return Ok(info);
        }
    }
}


In this example, the GetServiceInfo action method uses [FromServices] attribute to directly inject the IMyService instance into the method parameter. ASP.NET Core will automatically resolve the service and provide it to the action method.

It's important to recognize that while leveraging [FromServices] can be advantageous under specific circumstances, the preferred approach for enhanced maintainability and testability—especially when a service is required across multiple action methods—is to opt for constructor injection (the constructor of the [Controller]).