This one that the previous company came into contact with, it is not very in-depth, write here to record, if it is wrong, please correct it
First, create an MVC project and add Autofac directly via Nuget.
Autofac 4.9.1
Autofac.Mvc5 4.0.2
Create a library project
Add IService.cs to locate the one you want to registerService assembly
Add MessageService.cs, UserService.cs, as a service that needs to be injected
Add ServiceLocator.cs to the web project to obtain the specified service to be injected
Include the registration code for dependency injection in Global.asax
There are two methods that can be used to get the injected service
Source:The hyperlink login is visible. Extraction code:Tourists, if you want to see the hidden content of this post, please Reply
|