How to Update (Add/Modify/Delete) keys in AppSettings section of web.config at runtime

前端 未结 4 754
闹比i
闹比i 2021-01-12 23:11

I like to Update keys/Values defined in AppSettings section of Web.config at runtime. however I DO NOT want to actually save them to Web.conf

4条回答
  •  忘掉有多难
    2021-01-12 23:45

    I know this is an old question, but I ran into the same problem and I found that Set works in the same way as Add, and does not throw an exception, so just replace Add with Set, like so:

    ConfigurationManager.AppSettings.Set(item.Key, item.Value);
    

提交回复
热议问题