ConfigurationSettings.AppSettings vs. IIS Application

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am curious to know if there are performance issues in choosing between A and B. Which performs best?

A. store string values in the web.config and pull them using ConfigurationSettings.AppSettings

B. Use Application_OnStart to store string values in Application variables
 
I would guess that the Application variables would be faster. The Web.config
is cahced anyway, but Application_Variables are "permanently cached" in a
manner of speaking.

Storing data in static variables/static class properties would be faster
than both of them.
 
JMD said:
I am curious to know if there are performance issues in choosing between A and B. Which performs best?

A. store string values in the web.config and pull them using ConfigurationSettings.AppSettings

B. Use Application_OnStart to store string values in Application variables

Actually, if you're concerned about performance, you might want to do
performance testing in your own environment. If there were performance
differences, they might depend on the environment.

As it happens, there would be little difference, except perhaps readability
differences. ConfigruationSettings.AppSettings caches the values from
web.config, so even if you reference them on every page, there should be
little performance hit.
 
My guess is that most applications wouldn't notice a signifigant
performance difference between the two options. My only concern with
Application variables is that the runtime has to acquire a
ReaderWriter lock before retrieving an object from the collection.
This should not be a signifigant overhead in most applications, but
only some testing and benchmarking could tell.

Another option is to expose the strings through static properties on a
class, perhaps the Global class in global.asax. Read them once from
web.config and then they are easy to grab from anywhere in your code
with code like Global.MyString. The other benefit of this approach is
that the source of the string, be it the web.config file or somewhere
else is abstracted away.
 
Back
Top