Skip to content

Reload IConfiguration at runtime and have updated values on IOptionsMonitor.OnChange #13047

Answered by Ghevi
Ghevi asked this question in Q&A
Discussion options

You must be logged in to vote

Well dumb me 😊, the mistake is that using this line
JsonSerializer.Serialize(new AppSettings { ConnectionString = "start string" })
the file content will be {"ConnectionString":"start string"}

If i want this result {"AppSettings":{"ConnectionString":"start string"}}
i should do JsonSerializer.Serialize(new { AppSettings = new AppSettings { ConnectionString = "start string" } })

Woowiiee, i have the updated options in the optionsMonitor.OnChange callback now.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by Ghevi
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant