Difference Between IOptions, IOptionsSnapshot, IOptinosMonitor
The Options pattern uses classes to provide strongly typed access to groups of related settings and helps to satisfy Encapsulation and Separation of concerns principals .options also provide a mechanism to validate configuration data. So when working with options pattern it provide three interfaces to inject the configuration into your services. IOptions, IOptionsSnapshot, IOptinosMonitor, so in this article we will talk about the difference between these interfaces.
πππ©ππ’π¨π§π¬ π’π§πππ«ππππ
The lifetime of the IOptions interface is Singleton, and you can register it in any service lifetime. It has one limitation: when you start your app, and after starting, you change something in your configuration, it will not pick up the new configuration.
πππ©ππ’π¨π§π¬ππ§ππ©π¬π‘π¨π π’π§πππ«ππππ
The lifetime of the IOptionsSnapshot interface is Scoped because it is scoped; therefore, you cannot use this in your Singleton services. It is useful in scenarios where options should be recomputed on every request.
πππ©ππ’π¨π§π¬ππ¨π§π’ππ¨π« π’π§πππ«ππππ
The lifetime of the IOptionsMonitor interface is Singleton, and you can register it in any service lifetime, just like the IOptions interface.
However, IOptionsMonitor can read the latest configuration from your app settings even after you start your app; this is the major difference between the IOptions and IOptionsMonitor interfaces. The name of the property that stores the config value is CurrentValue instead of Value.



