Skip to main content

Posts

Showing posts with the label ControllerFactory And StructureMap

ASP.NET MVC 4 - ControllerFactory And StructureMap

StructureMap is an IoC container that we can use to inject implementations into the client. To do this in ASP.NET MVC we will use the constructor of the controller. Create a new ASP.NET MVC 4 project and install StructureMap via NuGet. When the package is installed a reference to StructureMap is automatically created. Create a class named  BootStrapper  inside the root of the MVC project with the following code listing: ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 using StructureMap; using StructureMap.Configuration.DSL; using Mvc4ControllerFactoryAndStructureMap.Services; namespace Mvc4ControllerFactoryAndStructureMap {      public class BootStrapper      {          public static void ConfigureDependencies()          {       ...