PM> install-package Unity.Mvc3Yes, that is the correct version even for MVC 4 (at least at the time of writing).
Bootstrapper.cs file will be created in the project.
Next, inside Applicaton_Start() in Global.asax.cs, put this code:
Bootstrapper.Initialise();
Then register our components inside BuildUnityContainer() method in Bootstrapper.cs. For example:
. . . container.RegisterType<IColourRepository, ColourRepository>(); container.RegisterType<IInvoiceRepository, InvoiceRepository>(); . . .
Calling container.RegisterControllers() in order to register controllers is no longer required in recent version.
No comments:
Post a Comment