web.config vs. application object

  • Thread starter Thread starter RedHair
  • Start date Start date
R

RedHair

In ASP.NET web application, where is the best place
to store a application scope variable?(read only)
Web.Config file or application object?
Which performance is better while reading the data?
 
Well, you should initially store them in the web.config to make them easier
to change. You can then read them out of there into the Application() object
on Start. Web.Config data is cached in memory after the first
read....Application is probably faster, but if so it's by a very very very
small amount. I'd sick with web.config.

Karl
 
Thanks.
Currently, I'm doing the same way as your suggestion, store them in
web.config
but read and store them in app object in app_start event, I just wonder if
this is
a redundant step?

By the way, if both web.config data and app object are cached in memory, how
come reading from app object will be faster?



"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> wrote in message news:%[email protected]...
 
I think it's redudant.

I'm only guessing at the speed...web.config might be faster. But I'm
thinking the configuration structure is more complicated than the Hashtable
structure the Application object uses. Maybe it isn't. Maybe AppConfig uses
a NameValueCollection which would likely be even faster. For example,
retrieving an int (which is sitting on the stack) is going to be faster than
getting an dataset...even though they both sit in memory :)

Also, if you are looking to get the most out of your configuration, take a
look at:
http://openmymind.net/index.aspx?documentId=5

Karl
--
http://www.openmymind.net/



RedHair said:
Thanks.
Currently, I'm doing the same way as your suggestion, store them in
web.config
but read and store them in app object in app_start event, I just wonder if
this is
a redundant step?

By the way, if both web.config data and app object are cached in memory,
how
come reading from app object will be faster?



"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> wrote in message news:%[email protected]...
 
Thanks for your reply.
Do you know how to calculate the memory occupied by a app object?
It depends on the data length?


"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> ¼¶¼g©ó¶l¥ó·s»D:%[email protected]...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top