asp.net-core Retrieve dependencies on a Controller


Example

Once registered a dependency can be retrieved by adding parameters on the Controller constructor.

// ...
using System;
using Microsoft.Extensions.DependencyInjection;

namespace Core.Controllers
{
    public class HomeController : Controller
    {
        public HomeController(ITestService service)
        {
            int rnd = service.GenerateRandom();
        }
    }
}