ConfigurationsΒΆ

Configurations and variables are used to provide configuration parameters to the web application. You can manage them (add, edit, and delete) from the backend using the Administration/Configurations section:

../../_images/16.png

Each configuration has code and name:

../../_images/24.png

Code is used to get the configuration from code.

Configurations consist of variables. Each variable has code, name, value, and position:

../../_images/34.png

The same as for configurations, code is used to get the variable from code.

There is the special DefaultConfigurationManager class that you can use to operate the configurations. It implements the IConfigurationManager interface and it is registered as a service inside the DI, so you can replace it with your own implementation.

This is the usage example:

public class DefaultController : Controller
{
      public DefaultController(IConfigurationManager configurationManager)
      {
        string emailSmtpServer = configurationManager["Email", "SmtpServer"];
      }
}

Also, you can use the configurationBuilder.AddStorage() extension method:

IConfigurationRoot configurationRoot = new ConfigurationBuilder().AddStorage(storage).Build();

string emailSmtpServer = configurationRoot["Email:SmtpServer"];