multiple web.config files

Posted by Venkatesh under ASP.NET on 3/3/2011 | Points: 10 | Views : 9005 | Status : [Member] | Replies : 9
Hi,

Can we use mulitiple web.config files in single application.If yes
How to retrieve those values in two web.config files.and which config will be run for that application

Thanks & Regards
Venkatesh




Responses

Posted by: Vuyiswamb on: 3/3/2011 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
Yes you can , but they will cause a problem. What would you want to use many web.config? all different parts of your app can consume settings from one web.config.



Thank you for posting at Dotnetfunda
[Administrator]

Venkatesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Madhu.b.rokkam on: 3/3/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Yes you can have multiple web.config files but they should be in different folders ... Not more than 1 in any folder. The config in the root will be taken as default for the application point of view.

Thanks and Regards
Madhu

Venkatesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 3/3/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Yes defn u can use mutiple config files in the application but in diferent folders like a root folder, then a sub folder then a sub to sub folder... The root folders config will be the primary one. And Machine.config file will act as the master for all these configs...

Thanks
Karthik
www.f5Debug.net

Venkatesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 3/3/2011 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
but why would one do that ?

Thank you for posting at Dotnetfunda
[Administrator]

Venkatesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Madhu.b.rokkam on: 3/4/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
When in each folder we have seperate web.config. Then the files inside that folder will give first preference to the config files in the same folder. So this way we can have additional configuration settings like authentication or other app setting keys specific to that set of files. That way we make the parent one more readable too.

Thanks and Regards
Madhu

Venkatesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Venkatesh on: 3/4/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

Thanks for Replying
in one web.config file having
<appsettings>
<add key="First" value="Dotnet">
<add key="Second" value="Dotnetfunda">
</appsettings>

second web.config file

<appsettings>
<add key="root" value="Dotnet">
<add key="root" value="Dotnetfunda">
</appsettings>


these web.config files are used in single application how to retreive these values.

First web.config file will be in some folder
second web.config file will be in root

How to retrieve these values

Thanks
Venkatesh


Venkatesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 3/4/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Hi,

You need to retrive value from which webconfig? from the root folder or from the sub folders?

Thanks
Karthik
www.f5Debug.net

Venkatesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Venkatesh on: 3/4/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

I want to retrieve values from two web.config files

Thanks & Regards
Venkatesh

Venkatesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 3/4/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Check this link

http://www.codeproject.com/KB/aspnet/multipleWebConfig.aspx

Thanks
Karthik
www.f5Debug.net

Venkatesh, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response