I am using ConfigurationManager.AppSettings["smtpHost"] to read a value from the app.config file in my business logic layer, but the value returned is always null, even though the key exists and it has a value, Does any one know why?
App.config file in BLL:
<appSettings>
<add key="smtpHost" value="smtp.gmail.com" />
</appSettings>
I added the same thing to the web.config file.
And I try to get;
var host = ConfigurationManager.AppSettings["smtpHost"];
Your code is correct (i have tested), you need to make sure that your app.config file is in your main project (exe).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With