Possible invalid lifetime for EmailService
phorks opened this issue · 3 comments
phorks commented
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
mehmetozkaya commented
so what is your recommendation ? should I use singleton on there ?
phorks commented
Yes. If you intend to have a single instance of EmailService for all requests, singleton is the appropriate lifetime.
mehmetozkaya commented
thanks for sharing this. I will consider and refactor this part. thanks.