Hi,
I need to read values from different config file say web1.config instead of default web.config. How can i achieve this??
badly stuck , please help..
Any help will be greatly appreciated.
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sunny SharmaRank #223 · 11.1K reputationPosted Sep 12, 2013, 6:48 AM EDT
I've created a sample app for you that is attached herewith, depicting how it works. Please go through.
Hope it helps!
Happy Coding :)
Sunny SharmaRank #223 · 11.1K reputationPosted Sep 11, 2013, 9:26 PM EDT
You can do this with very ease and can read any of/number of config files. Follow the syntax below:
----------------------------------------------------------
System.Configuration.KeyValueConfigurationCollection settings;
System.Configuration.Configuration newConfig;
System.Configuration.ExeConfigurationFileMap configFile = new System.Configuration.ExeConfigurationFileMap();
configFile.ExeConfigFilename = "otherWeb.config";
newConfig=System.Configuration.ConfigurationManager.OpenMappedExeConfiguration(configFile, System.Configuration.ConfigurationUserLevel.None);
settings = config.AppSettings.Settings;
-------------------------------------------------------------
Happy Coding :)
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Sep 11, 2013, 9:29 PM EDT
refer to this link it may help you:
http://dotnet.dzone.com/news/working-more-one-webconfig
syed afroz46 reputationPosted Sep 11, 2013, 10:03 PM EDT
Suthish NairRank #92 · 22.8K reputationPosted Sep 13, 2013, 3:41 AM EDT