I have some global settings For example some below are
ShortLeaveAllowedInOneDay = 2
LeaveAllowedInMonth = 3
I have following options to store these global settings
1-Store in Database table
2-Store in Webconfig file
3-Store in class as const filed
4-In XML file
Could you please suggest me which one is better approach and why
I am using Asp.net MVC3 with sqlserver 2005
It depends on your requirements, each one of these options has it own advantages and disadvantages. It tried to list a few:
1. Store in Database table
Advantages:
Disadvantages:
2. Store in web.config file
Advantages:
Disadvantages:
web.config
may result in the application pool to restart.
3. Store in class as const field
Advantages:
Disadvantages:
4. In XML file
Advantages:
log4net
as one such example)Disadvantages:
If you need them to be configured by a user of your software I would not do option 3. If they are settings that you define as a programmer and do not expect them to be changed when your application is in production you could do that.
I would say that option 4 and 2 are basically the same, conceptually, and it is personal preference which to choose. Personally I like to define a custom configuration section and then have just that section defined in it's own .config file (this shows how to do that) so that you don't have a really massive web.config that the user has to navigate.
I would choose option 1 if I had a scenario where I had multiple components that all need access to the same configuration. If all you are building is a single web application, it does not feel necessary to me to do that but if, for example, you have a web application and some other client application and both require access to the database then storing the configuration there is a good choice.
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