I came to the concept of using web.config as storage when I did a small application which deals with small amount of data.
The database is very costly compared to the size of the application.I was in need of some KBs for data storage.
The other option was to store data in text file.But there is one security issue.Anybody can download the file using it's URL.This can be fixed by writing some more code like HttpHandlers.But that will make the application more complex.
So decided to go with web.config as Data source.
Here is the code to store data into web.config.
//Opens the web.config at root level.
Configuration cfg = WebConfigurationManager.OpenWebConfiguration("~");
//Change value
cfg.AppSettings.Settings["options"].Value = "hello";
//Save the configuration
cfg.Save();
Using web.config as data source is applicable only if the size of the data is very small (Some KBs).
No comments:
Post a Comment