1

Could you please tell me how we will use more than 1 web.config file in asp.net?

3
  • Can you explain a bit why you want to use more than one web.config file? What is it that you want to achieve? Commented Apr 11, 2011 at 10:50
  • this is the requirement of our project, we are developing our website Commented Apr 11, 2011 at 10:52
  • yes, but for what purpose? You can put different web.config files in different directories for security settings and similar. You can also break out portions of a web.config into other config files and reference them using the configSource attribute, in order to break up a large config file into smaller pieces. These two serves completely different purposes. So the question is: for what purpose do are you planning to use several config files? Commented Apr 11, 2011 at 11:24

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

Comments

1

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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.