Sometimes I need to set some string values from code, for example:
Page.Title = "This is a test page.";
or
lblSupportInfo.Text = "Please contact xxx-xxx-xxxx for support.";
These are just examples of data that can change anytime. Is it better stored in the settings file in application scope? What are other options.
It would be better to be able to change this by updating a configuration file rather than a code release (Resources).
How do other people handle this? If there are too many of them, the web.config can be very long.
I prefer to store such items in a database, as updates are a LOT easier than updating a .config file, or code. Most commercial software that I've worked with does the same.
If a DB isn't an option, then the .Config files or some other text file will do. Even an XML file would work as a viable option. With a separate XML file or text file, you also avoid the hassle of losing the session state of your users, which happens if you update the .config file and are using the standard in-proc session management.
In one of our applications, we use an XML document that was created by filling a Dataset from a database, and then using the Dataset's WriteXml() function to preserve the data as a file that can be deployed with the application. This is specifically intended for a group of people who are on the road, and can't always connect to the server to get the most recent data. The data is used to populate a survey form for secret shoppers. Their results are also saved in teh same way, and serialized on the laptop. When they connect to the corporate network, the results are uploaded via a web service, and processed into the results tables in the database.
We use a Key Value Pair in the Database. We load that key value pair into the Cache and then create Static Class for getting the values in Code on demand and easily. We make an admin page for clearing them out of cache when needed and the code recognizes that they have been clear and relaods them into cache on demand. This can be expanded to deal with other languages and be plugged into all other models as needed, however I would imagine you want want to only use it the Presentation layer. You can key you custom exceptions and then catch them in the presentation layer and that key will correspond to the appropriate message. This would give a Robust environment with lots of potential for growth. Hope this Helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With