Get settings
IConfiguration<>
is the main service to read settings.
Example: Inject IConfiguration<>
into a application service:
Important thing that, in this example if you register EmailService
as scoped, then private readonly field _settings
that contains SmtpEmailSettings
will not modified even origin SmtpEmailSettings
will be changed. This will happen because you get settings SmtpEmailSettings
from IConfiguration<SmtpEmailSettings>
in the constructor.
So if you need get actual settings realtime, you should preserve IConfiguration<SmtpEmailSettings>
in application service:
Last updated