1 Dec
2022

Refactoring Bloated Controllers with [FromService]

In my previous article, Refactoring Bloated Controllers with IServiceProvider, I explored using the Service Locator Pattern to reduce the number of services injected into an ASP.NET MVC controller constructor. While a convenient way to reduce the number of constructor arguments, using IServiceProvider does have some potential downsides. It has been a few years since I […]

Read More
Bloated
26 Nov
2022

Refactoring Bloated Controllers with IServiceProvider

I have come into an ASP.NET MVC project that has a HomeController that takes at least 10 service arguments in its constructor. My first line of attack is to factor out the Action methods into separate controllers that only need a subset of the injected services to work properly. So, first and foremost I recognize […]

Read More