应用可变VS Web.Config中的变量 [英] Application Variable Vs Web.Config Variable

查看:91
本文介绍了应用可变VS Web.Config中的变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是从性能的角度更好呢?

Which is better from a performance perspective?


  • 访问全局应用程序变量(应用程序[富])


  • 从web.config中访问的AppSetting变量

.NET是否缓存中AppSetting变量,这样它不与每次使用访问web.config文件?

Does .NET Cache the AppSetting variables so that it is not accessing the web.config file with every use?

推荐答案

这两件事情没有可比性。 的appSettings ,或任何其他的配置设置,是的配置的设置。 应用变量对于批量应用的过程中可能会发生改变,或者是对于像域数据值表。后面的这些事是你不会放入一个配置文件,因为它们改变很少,并且不必被配置

These two things are not comparable. appSettings, or any other configuration settings, are for configuration settings. Application variables are for quantities that might change during the course of the application, or are for things like tables of domain data values. These latter are things which you would not place into a configuration file, because they change rarely, and do not need to be configured.

的appSettings ,并在配置文件中其他的一切,被缓存。该文件是只读的每个AppDomain一次,一般。事实上,当你改变你的web.config,它会导致一个AppDomain重新启动,主要是让新的配置设置可以被读出。

appSettings and everything else in a config file, is cached. The file is only read once per AppDomain, in general. In fact, when you change your web.config, it causes an AppDomain restart, mainly so that the new configuration settings can be read in.

这篇关于应用可变VS Web.Config中的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆