I have a web application which is using a dll of a class library. I am unable to access the app.config
value in the class library
How I'm trying to access app.config
:
ConfigurationSettings.AppSettings["conStr"].ToString();
this is returning a null value
Also when I try to use ConfigurationManager
it says not found or missing assembly reference.
using System.Configuration is also added .
You must put the AppSettings
value inside the web.config
of the application, because it override the app.config
from the class library.
Add a reference to System.Configuration
namespace in the class library project, them get the value you're expecting from the web.config
file, not from the app.config
file.
Add a reference to the System.Configuration
library in your project, then get your key like this
ConfigurationManager.AppSettings["conStr"]
Notice that a web application will search for a web.config
file and not an app.config
!
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