james2code
james2code

Reputation: 894

Application Variable Vs Web.Config Variable

Which is better from a performance perspective?

versus

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

Upvotes: 3

Views: 864

Answers (2)

John Saunders
John Saunders

Reputation: 161773

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 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.

Upvotes: 5

AndrewVos
AndrewVos

Reputation: 1295

appSettings are apparently not cached

EDIT: Seems both appSettings and Application variables would be the same speed then. After the initial load of course.

Upvotes: 0

Related Questions