ASP.NET Web.config AppSettings 性能
我在 web.config 中有许多经常使用的 appSettings(即在每次回发时)。 ConfigurationManager 是否在进程中保存这些值,或者通过将这些值复制到 ApplicationStart() 上的应用程序状态并随后从那里检索它们是否可以获得任何性能提升?
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
AFAIK 在启动时读取并解析配置,然后将数据保存在内存中。我认为在应用程序变量中缓存状态不会带来任何显着的性能提升 - 尽管您可能会提高可读性,因为您不会使用
ConfigurationManager.AppSettings[...]
乱七八糟地编写代码。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[...]
.