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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sunny SharmaPosted Sep 12, 2013, 10:48 AM
I've created a sample app for you that is attached herewith, depicting how it works. Please go through.
Hope it helps!
Happy Coding :)
Suthish NairPosted Sep 13, 2013, 7:41 AM
syed afrozPosted Sep 12, 2013, 2:03 AM
Sanjeeb LenkaPosted Sep 12, 2013, 1:29 AM
refer to this link it may help you:
http://dotnet.dzone.com/news/working-more-one-webconfig
Sunny SharmaPosted Sep 12, 2013, 1:26 AM
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 :)