DEV Community

Arun Kumar
Arun Kumar

Posted on

2

Today I learned some stuff about .NET Core configuration

If we make any changes to appsettings.json file, the IConfiguration object will get updated on runtime.

But IOptions<MyClass> wont get updated like that so you need to use IOptionsMonitor<MyClass> or IOptionsSnapshot<MyClass>. (All three of them are from the same namespace Microsoft.Extensions.Options)

IOptionsMonitor<MyClass> is singleton, so any mutation you make to this object will persist throughout the life of the application.

IOptionsSnapshot<MyClass> is scoped, so any mutation you make to this object will be thrown out when the request finishes its life.

I learned this from Nick Chapsas in YouTube. URL
Keep coding.

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay