Jad*_*ias 43 .net asp.net performance caching configurationmanager
我们知道IIS缓存ConfigurationManager.AppSettings,因此它只读取磁盘一次,直到更改了web.config.这样做是出于性能目的.
有人在:
http://forums.asp.net/p/1080926/1598469.aspx#1598469
表示.NET Framework不会对app.config执行相同操作,但它会从磁盘读取每个请求.但我觉得很难相信,因为它会变慢.请告诉我他错了或者我必须修复我写的每个控制台/ Windows窗体/ Windows服务.
更新我很遗憾我误解了人们在上面的链接论坛中所说的内容.
Zom*_*eep 49
快速测试似乎表明这些设置仅在应用程序启动时加载.
//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();
Run Code Online (Sandbox Code Playgroud)
您会看到所有输出保持不变.