Question

I have a .NET application that needs to reference a global application variable, a number, which is used by the application to allow/disallow users to enter events prior to a date. Currently I have

<appSettings>
    <add key="beginDateRangeDays" value="60" />
    <add key="endDateRangeDays" value="30" />
</appSettings>

in my Web.config. I want the admin users to be able to modify those values periodically via an admin web page. If I allow this, every time they make a change, my app pool will restart.

Where would you recommend storing this? In an external config file? But will that also cause an app pool restart? Should I use a config table in the application's database?

Was it helpful?

Solution

I want the admin users to be able to modify those values periodically via an admin web page

Database, definitely. The config file is a convenient place to store non-static values, but not always the best place. Step back for a moment and consider two "buckets" of such values:

  1. Logical configurations which users can change within any given instance of the application.
  2. Infrastructure configurations which define any given instance of the application and how it relates to the surrounding environment.

The former is best kept in the application's database, the latter in the config file. The former might contain values like:

  • Business holidays observed this year
  • Values used in calculating business data
  • Defaults for user forms

While the latter might contain values like:

  • Database connection strings
  • URLs for external web services
  • Credentials for service accounts

Let the users change things that they can change without physically breaking the application, and track those changes in the database. Keep the infrastructure details in the config file, since a change to those details would very likely require an app pool restart anyway.

OTHER TIPS

You should be able to setup application settings, such that they are editable in IIS. See this TechNet article:

http://technet.microsoft.com/en-us/library/cc753062(v=ws.10).aspx

If you store it in the database then you have control over who accesses it and when. Then you need not worry about making the app pool restart.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top