Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 267
  • Last Modified:

ASP.NET - Best Place to load Global settings??

Hi,

Cannot seem to find a decent answer so figured someone here would know.

I have an asp.net app that allows a worker to edit certain parts of webpages, these are stored in a db, most of this is  font types, colors, text html etc.

I am wondering if there is a way to somehow save these settings on application (global?) level so that the database need not be hit for each visitor, but if possible to have the app load these settings maybe once a day or only when some one has changed a setting, thus not requireing a hit each time a new visitor reads the page.


Thanks
0
flosoft
Asked:
flosoft
  • 2
  • 2
1 Solution
 
coopzzCommented:
well i think MS new way of doing this is in the web.config file, using app settings  eg:

web.config file extract
-----------
<configuration>
  <appSettings>
    <add key="textColor" value="green" />
  </appSettings>
  <system.web>
  etc.....
----------
and this is how to get it
----------
System.Configuration.ConfigurationSettings.AppSettings("textColor")
----------

And when this file is changed the web app restarts and reloads.

CooPzZ
0
 
flosoftAuthor Commented:
HI thanks for the comment,

I am storing my connection string in the web.config in a simular fasion, but doing it this way wouldn't it have to read the file every time new visitor arrived? or does it store those settings in memory of the server so no hard disk hit is needed?

Thanks
0
 
coopzzCommented:
TO be honest I never actually tested it in that way [they don't seem to mind calling a conection string everytime you grab a connection so I never put too much thought into it yet], If your only catering for less that 100 users at a time I wouldn't worry too much, Time To Do some reasearch I guess.

Well If you really want to make sure it's in memory in your global.asax file load all your vars into the applicaiton.contents object.. on the app_Start event so even when the web.config file gets change it will repass though the same procedure and set them up again and then It will be stored in memory.

CooPzZ
0
 
flosoftAuthor Commented:
Thanks!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now