✅ How to edit and save specific appsettings.json (project root) section?
Hello, I have issue with editing specific section in the appsettings.json in project root folder, but now it overwrites all he file although it should overwrite only the specific section
30 Replies
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
I use on the local env. This is service function which used on the api endpoint
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
nope, I do just API call.
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
inside controller aka endpoint
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Also, I do in this Startup.cs to bind this section
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
appsettings.json:
src/Foo/FooOptions.cs:
src/Foo/FooServiceCollectionExtensions.cs:
Program.cs / Startup.cs:
Bar.cs:
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
But I must have option for user aka admin to set a value
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
because one of requirements make that value editable. So system admin must change value who can be non-tech person
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
value is must set configurable runtime
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
The case if for some reason you can't save the value sucessfully
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
That is the case I faced prieviously when value is saved on the bin/debug edition of the appsettings.json so the value be 1
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
It depends if have reload on change or not
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
If saved in the DB it would be fine but I'm not 100proc sure about some kind of the file
tebeco#0205
sounds like what Azure AppConfiguration does / could do
Quoted by
<@!689473681302224947> from #How to edit and save specific appsettings.json (project root) section? (click here)
React with ❌ to remove this embed.
Much safer case have custom json with user configurable values
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Sorry, but I'm not hosting this project on the free Azure plan
but if hosting would be the case, I must pretty aware of that.
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.