Closed phorks closed 3 years ago
so what is your recommendation ? should I use singleton on there ?
Yes. If you intend to have a single instance of EmailService for all requests, singleton is the appropriate lifetime.
thanks for sharing this. I will consider and refactor this part. thanks.
According to the course lectures, the reasoning behind registering the email service as transient is to prevent the service from being created for every request and to use a single instance throughout the application lifetime. This means that the service must be registered as singleton since transient means a new instance will be created EVERY TIME the service is requested from the dependency injection framework. Code