ConfigurationManager.AppSettings Caching

前端 未结 6 2230
北恋
北恋 2020-12-29 20:13

We know that IIS caches ConfigurationManager.AppSettings so it reads the disk only once until the web.config is changed. This is done for performance purposes.

Someo

6条回答
  •  梦毁少年i
    2020-12-29 20:39

    A quick test seems to show that these settings are only loaded at application startup.

    //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();
    

    You'll see that all outputs remain the same.

提交回复
热议问题