What are the differences between IOptions and IOptionsSnapshot?

IOptions:

  • Options configured in IOptions are registered as SingletonServices
  • Can be injected into any service for accessing options
  • Doesn't support option updates when configuration changes
  • Doesn't support Named options

IOptionsSnapshot:

  • Options configured in IOptionsSnapshot are registered as ScopedServices
  • Can be injected into only Scoped and Transient services
  • Supports updated options even after configuration is loaded
  • Supports Named options

ASP.NET Core Posted Jul 09, 2020

You can now show your support. 😊

We use cookies to provide you with a great user experience, analyze traffic and serve targeted promotions.   Learn More   Accept