ASP.NET Web.config AppSettings性能

时间:2022-06-01 05:41:28

I have a number of appSettings in web.config that are used frequently (i.e. on each post back). Does the ConfigurationManager hold these values in process or are there any performance gains to be had by copying these values into application state on ApplicationStart() and subsequently retrieving them from there?

我在web.config中有很多appSettings经常使用(即在每个帖子后面)。 ConfigurationManager是否将这些值保存在过程中,或者通过在ApplicationStart()上将这些值复制到应用程序状态并随后从那里检索它们是否有任何性能提升?

1 个解决方案

#1


9  

AFAIK the configuration is read and parsed at startup and the data is held in memory thereafter. I don't believe any performance gains from caching the state in application variables will be significant - though you may get improved readability as you don't litter the code with ConfigurationManager.AppSettings[...].

AFAIK在启动时读取并解析配置,此后数据保存在内存中。我不相信在应用程序变量中缓存状态会带来任何性能提升 - 尽管您可能会提高可读性,因为您不会使用ConfigurationManager.AppSettings [...]丢弃代码。

#1


9  

AFAIK the configuration is read and parsed at startup and the data is held in memory thereafter. I don't believe any performance gains from caching the state in application variables will be significant - though you may get improved readability as you don't litter the code with ConfigurationManager.AppSettings[...].

AFAIK在启动时读取并解析配置,此后数据保存在内存中。我不相信在应用程序变量中缓存状态会带来任何性能提升 - 尽管您可能会提高可读性,因为您不会使用ConfigurationManager.AppSettings [...]丢弃代码。