ASP.NET Core profile Savin

I read the appsetting.json configuration of ASP.NET Core in the following ways

services.Configure<MyConfigs>(Configuration.GetSection("MyConfigsSection"));

the configuration is read out and injected into Controller or Class using
, but in this way, it seems that the data can only be read out, and the new value cannot be written back to the "MyConfigsSection" of appsetting.json

.

how to write the new value back or is there any better way to save the program configuration (readable and writable)

Thank you very much


just modify the appsetting.json file directly, which is hot overloaded by default.
for example, add or delete JObject.Parse and use IO API ( IO.File.WriteAllText ) to write the ToString content of the previous object, which includes an option of whether to indent or not. You can also directly use Serialize of JsonSerializer .

Best practices for program configuration, depending on the application.

The configuration options of

ASP.NET Core are very flexible. You can first check out the official documentation:
https://docs.microsoft.com/zh.

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e90a02-470a9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e90a02-470a9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?