Reputation: 11
Could you please tell me how we will use more than 1 web.config file in asp.net?
Upvotes: 1
Views: 1974
Reputation: 61775
You can't use multiple web.config files as far as I know. You can however run create a new website that uses a different web.config file and has duplicate files.
If there is a particular setting you want to be variable, then your design sounds a bit inefficient and you should probably be handling those values outside the web.config file.
You can also split your config file into multiple parts, which is useful if it's hard to manage and want to modularise it. Do as follows:
Your Main.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings file="YourSettings.config" />
<system.web>
<!-- Continue as normal -->
</system.web>
</configuration>
Then create YourSettings.config
<!-- Referenced by Web.config -->
<appSettings>
<add key="Key" value="MyVal" />
</appSettings>
Upvotes: 1
Reputation: 19618
You can use multiple web.config in different directories in the web application. This will help you to override any parent folder config settings
Multiple Web.Config files in ASP.NET web application
Upvotes: 2