Like Console Application, we can follow the same procedure to deal with dependencies inside ASP.NET Core MVC 2.0 apps. Unlike the console app, the Main
method inside the Program.cs
, in this case, is populated with default codes to initiate the MVC App with required configurations. It is that location from which it instructs the framework to load the Startup class. The host
inside the Main
method executes the Startup
class ConfigureServices
method.
ASP.NET Core MVC is designed to be DI-friendly. But it does not force you to apply DI always. To deal with dependencies in ASP.NET MVC, we can take the Poor Man's DI approach to manually manage them or leverage built-in/third party DI Container's technique to register, resolve, and release dependencies. Let's dive a little deep into the controller initiation process and see if we find anything useful.
The heart of MVC lies in controllers. Controllers handle requests, process them, and return the response...