Asp.net
ConfigurationManager.AppSettings 記憶體
我們知道 IIS 記憶體 ConfigurationManager.AppSettings,因此它只讀取一次磁碟,直到 web.config 被更改。這樣做是出於性能目的。
某人在:
<http://forums.asp.net/p/1080926/1598469.aspx#1598469>
表示 .NET Framework 對 app.config 的作用不同,但它會從磁碟中讀取每個請求。但我很難相信,因為它會更慢。請告訴我他錯了,否則我將不得不修復我編寫的每個控制台/Windows 窗體/Windows 服務。
更新我很遺憾我誤解了人們在上面連結的論壇中所說的話。
快速測試似乎表明這些設置僅在應用程序啟動時載入。
//edit the config file now. Console.ReadLine(); Console.WriteLine(ConfigurationManager.AppSettings["ApplicationName"].ToString()); Console.WriteLine("Press enter to redisplay"); //edit the config file again now. Console.ReadLine(); Console.WriteLine(ConfigurationManager.AppSettings["ApplicationName"].ToString()); Console.ReadLine();您會看到所有輸出都保持不變。