Approaches to configure and configure applications (in ASP.NET MVC)

For a CMS product / platform, what would be a convenient and understandable approach for editing and saving settings?

I'm not talking about technical parameters (connstring, nh config, ...), but about settings that change the behavior of the product:

These settings, for example,

  • Online Payment Settings
  • Available Parts and Modules
  • Default behavior of the application (showing details of the default list item, default landing page after certain actions)
  • ...

At the moment, we do not have an approach, so the result is that all the settings end in the web.config file.

This is probably not the best approach since it just ends with an endless list of obscure key value pairs ...

In this case, we also cannot predict types (without codegen), so settings with flags or predefined parameters ... are difficult to manage.

Another option would be to create the necessary tables for each parameter (type) and use it as a basic configuration system, but it will be more difficult to deploy and manage each client.

I have many answers to this question, but in reality this is not a top-down solution.

What I mean from top to bottom:

  • Editing Settings (Admin Screen)
  • Where to save settings
  • Download settings without much hassle, but still supported way
  • Save / Deploy Client-specific Settings

So, the options are:

  • (web) .config
  • .settings files
  • Db

But these are all key value based approaches ... Any other suggestions?

+4
source share
2 answers

You can write a custom configuration section that allows you to store much more than the key / value settings in the configuration file. The configuration file is intended for read-only settings. If you need editing features with admin screens, it is best to use a database. Saving this information in files is also possible, but since it is a multi-threaded application, you need to correctly synchronize access to those files, which can quickly become cumbersome.

+1
source

Basically you can create a settings table. includes the Name and Value fields. And you can save the settings.

public class Setting : Entity { public int Id { get; set; } public string Name { get; set; } public string Value { get; set; } } 

The table will have many rows to install. This structure is basically the use of a key-value pair. But! My advice is using the structure below.

 public class Setting : Entity { public int Id { get; set; } public string SiteName { get; set; } public string ProductsPerPage { get; set; } ... } 

Because it will be easy to cache. You can get the whole settings table and just cache it. Simple caching and more requests.

0
source

All Articles