{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"Communication": {
"Enable": "false"
},
"AllowedHosts": "*"
} In above code check the highlighted piece of code. Here this key will represent that is Communication -> Enable is false system is not allowed to send any email communication. On other had if it is true, system will slow to send the email communication. This approach will mostly help you in a scenario where you are doing development and you don't want to send any email of SMS communication, while development or in any of the lower environments. So, while moving to production you need to enable the name to make this value "true".
So here true means send the communication and false means don't send communication. So while moving to PROD you can make the change as shown below.
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"Communication": {
"Enable": "true"
},
"AllowedHosts": "*"
} Here in above code i have make communication enable. Here we will get the value from appsettings.json file at controller end using C#.Net.Example
[HttpGet]
public IActionResult Index()
{
return View();
}
[HttpPost]
public IActionResult Index(UserModel userModel)
{
var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json", optional: false);
IConfiguration config = builder.Build();
string comenable = config.GetValue<string>("Communication:Enable");
if(comenable == "true")
{
//code send email or SMS
}
return View();
}
Here if communication is enabled on that case user will display communication is enable on other hand if Communication Disable user will receive communication is disabled. You can make the call of you email or SMS sending method by applying if condition.