ConfigurationManager.AppSettings[key] is always null
- by Copeleto
Hi,
I am trying to get the value for the key "sUser" in this appSetting
http://coomeva1/AsisaWS_2008/ConsultaNuips.asmx
http://coomeva1/AsisaWS_2008_Sec/ConsultaNuips.asmx
http://coomeva1/AsisaWS_2008/ConsultaCedulaExtranjeria.asmx
http://coomeva1/AsisaWS_2008_Sec/ConsultaCedulaExtranjeria.asmx
userbancolombia
8909039388
this is the code on my class.cs
string sUsr = ConfigurationManager.AppSettings.Get["sUser"];
But always its null.
I try this code (I took it from http://msdn.microsoft.com/en-us/library/system.configuration.appsettingssection.settings.aspx):
// Get the configuration file.
System.Configuration.Configuration config =
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
// Get the appSettings section.
AppSettingsSection appSettings =
(AppSettingsSection)config.GetSection("appSettings");
// Get the auxiliary file name.
Console.WriteLine("Auxiliary file: {0}", config.AppSettings.File);
But it shows that the file Empty
Also I am ussing the consolo to write those properties and it works if I get the apps using
string sUsr = WIW.Business.Properties.Settings.Default.sUser;
But I am going to use that class as a reference in a website and on the web.config of the site i cant configure those
Thanks for your help