Do you know what to do about ASP.NET core (aka ASP.NET 5) default dependency injection?
11/02/2016 4:28 PM by
We already know what the best IOC container is, but how does ASP.NET core's default dependency injection compare?
ASP.NET 5 includes default dependency injection for new Web Apps in the Startup.cs file. This is adequate for simple projects, but not designed to compete with the features of alternatives containers (like AutoFac's convention based registration).
"The default services container provided by ASP.NET 5 provides a minimal feature set and is not intended to replace other containers." - Steve Smith, (ASP.NET Dependency Injection )
You can quckly flag this error and any more by using the SSW Code Auditor.
Here is an example of rewiring the default code to AutoFac with the SSW's Music Store app:
- Figure: Bad Example - The default dependency injection for ASP.NET 5
Figure: Good Example - The bad example rewired to utilize AutoFac. Red boxes outline the modified code.
Do you feel this rule needs an update?