Can we take multiple web.config files in single application

March 31, 2015 0 Comments

Yes,  we can take multiple web.config files in the single application. If we have a single directory then we can add multiple config file with different name. If you want to access xml tag from config file then you can access only web.config file elements. Lets take an simple example of the file.

web.config file

    <add key="first" value="My first web.config file"/>   

Default.aspx file

    <asp:Label ID="Label1" runat="server" Text="<%$appSettings:first%>"></asp:Label> 

Its working fine, but when we take another config file in the application then get the error like file not found error. So, i have a solution of this problem. Follow the mentioned steps to overcome this problem:
Step-1 : Add a new directory in the solution(application)
Step-2 : Add new web.config file in the newly created directory.
Step-3 : Also add a web form in the directory.
Step-4 : Now, you can easily access web.config file which is available in the newly created directory.

Jacob Lefore

Some say he’s half man half fish, others say he’s more of a seventy/thirty split. Either way he’s a fishy bastard. Google