Today I learned some stuff about .NET Core configuration

ajinspiro

Arun Kumar

Posted on March 2, 2022

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.

💖 💪 🙅 🚩
ajinspiro
Arun Kumar

Posted on March 2, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related