Base solution for your next web application
Open Closed

Where are settings stored? #2452


User avatar
0
paymanrowhani created

Hi,

Would you please clarify the following questions:

  1. I don't know where the modified settings are saved (as described in <a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Setting-Management">http://www.aspnetboilerplate.com/Pages/ ... Management</a>). I could not find them in AbpSettings table.
  2. Also, I don't know how to give default values for settings like "App.UserManagement.UseCaptchaOnRegistration". Should I set the value in app.config?
  3. Can we have the values from appsettings.json all over the solution?
  4. Are the values passed to setting providers aggregated or each module has only access to its own settings?

Thanks, Payman


6 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    1. Settings are stored in this table, AbpSettings. But if you don't have a setting value different than setting's default value, it is not stored here.
    2. You can give default values just like we do in AppSettingProvider class.
    3. Yes.
    4. Module settings are aggregated, a module can access another module's settings.

    I hope this helps. Please write back if there are unclear points.

  • User Avatar
    0
    paymanrowhani created

    Thanks for the responses.

    For #1, I still don't understand where other settings are stored if they are not in the table. Would you please clarify? For #3, would you please explain how it can be done and accessed?

    Thanks, Payman

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    For #1: All settings have default values, let's say you have a setting called MinPasswordLength has a default value of 6. So, at the beginning there is no value in the database because default setting value is defined and stored in code. When someone changes this setting for a tenant or for a user to 6, it is not written to database because it has the same value with the default value of setting. But if it is chagned to 5 for a tenant or user, then it is stored. After that, if someone changes it's value from 5 to 6 again, then the stored setting record is deleted from AbpSettings table. Please write back if you have a different case.

    For #3: AppConfigurations class is used for that. You can use it like this:

    var config = AppConfigurations.Get(
                     typeof(AbpZeroTemplateTestModule).Assembly.GetDirectoryPathOrNull()
                 );
    var multiTenancyConfig = config["MultiTenancyEnabled"];
    
  • User Avatar
    0
    paymanrowhani created

    Hi,

    Thank you so much! For #3, is it the way we can use the settings from appsettings.json in all projects or only in mvc/host project?

  • User Avatar
    0
    hikalkan created
    Support Team

    You can access to appsettings.json from any project, no restriction. You can use AppConfigurations.Get as shown.

  • User Avatar
    0
    paymanrowhani created

    Thank you :-).