The best situation is that dependent objects and data can be passed from Controller to View. But it can be used if it only involves front-end logic.be to inject Service into View, change the UI through the injected Service, import Configuration data to the front end, and re-cover the previously injected old Service. Under ASP.Net Core, service registration can choose different life cycles.
The life cycle of DI is divided into the following three types. You can choose different modes during registration according to different situations. Trancient: Register using AddTrancient. Each time a service is requested from the Service Container, a Service Instance canada dataset will be created. After use, the resources will be recycled by DI Container. Suitable for use in lightweight stateless services.
Scoped: registered using AddScoped. In every client request. No matter how many times it is requested to be called, it will only be established once. Singleton: Register using AddSingleton. A single Service Instance is created when the Configuration method is created or requested for the first time. The service will remain until subsequent clients can use the same Service Instance.