0
klainer created
Hello,
I need to override default SMTP server setting configuration. I created this class:
public class MySettingProvider : SettingProvider
{
public override IEnumerable<SettingDefinition> GetSettingDefinitions(SettingDefinitionProviderContext context)
{
return new[]
{
new SettingDefinition(
"SmtpServerAddress",
"192.168.50.14"
)
};
}
}
And in Web.Module I´m calling this:
public override void PreInitialize()
{
Configuration.Settings.Providers.Add<MySettingProvider>();
}
But this no work! What is correct appropoach to do it ? Thnaks !
5 Answer(s)
-
0
Here is my code for the overriding of the settings
I use those using statement :
using Abp.Configuration; using Abp.Net.Mail;
Setting Provider :
public override IEnumerable<SettingDefinition> GetSettingDefinitions(SettingDefinitionProviderContext context) { return new[] { new SettingDefinition( EmailSettingNames.Smtp.Host, string.Empty ), new SettingDefinition( EmailSettingNames.Smtp.Port, string.Empty ), new SettingDefinition( EmailSettingNames.Smtp.UserName, string.Empty ), new SettingDefinition( EmailSettingNames.Smtp.Password, string.Empty ), new SettingDefinition( EmailSettingNames.Smtp.EnableSsl, string.Empty ), new SettingDefinition( EmailSettingNames.Smtp.UseDefaultCredentials, string.Empty ) }; }
Seeder
if (!_context.Settings.Any()) { _context.Settings.Add(new Abp.Configuration.Setting { Name = EmailSettingNames.Smtp.Host, Value = "smtp.gmail.com" }); _context.Settings.Add(new Abp.Configuration.Setting { Name = EmailSettingNames.Smtp.Port, Value = "587" }); _context.Settings.Add(new Abp.Configuration.Setting { Name = EmailSettingNames.Smtp.UserName, Value = EMAILVALUE }); _context.Settings.Add(new Abp.Configuration.Setting { Name = EmailSettingNames.Smtp.Password, Value = PASSWORD VALUE }); _context.Settings.Add(new Abp.Configuration.Setting { Name = EmailSettingNames.Smtp.EnableSsl, Value = "true" }); _context.Settings.Add(new Abp.Configuration.Setting { Name = EmailSettingNames.Smtp.UseDefaultCredentials, Value = "false" }); }
-
0
Works, thanks !!
-
0
I have tried the same. Still not working for me. Can u pls help me?
-
0
Can u pls show me code sample and place of code change(core, application, etc)
-
0
Hi GOUSE,
Your case might be different. Do you have any data in database ? Can you share your Seed method of your DbContext and related classes ?
Thanks.